Files
rclone-ui/lib/rclone/mount.ts
2026-07-12 04:01:12 +03:00

50 lines
1.9 KiB
TypeScript

import { downloadDir } from '@tauri-apps/api/path'
import { ask } from '@tauri-apps/plugin-dialog'
import { exists, writeFile } from '@tauri-apps/plugin-fs'
import { fetch } from '@tauri-apps/plugin-http'
import { revealItemInDir } from '@tauri-apps/plugin-opener'
import { platform } from '@tauri-apps/plugin-os'
export async function needsMountPlugin() {
console.log('[needsMountPlugin]')
const currentPlatform = platform()
if (currentPlatform === 'windows') {
// check winfsp
const hasWinFsp =
(await exists('C:\\Program Files\\WinFsp')) ||
(await exists('C:\\Program Files (x86)\\WinFsp'))
console.log('[needsMountPlugin] hasWinFsp', hasWinFsp)
return !hasWinFsp
}
return false
}
export async function dialogGetMountPlugin() {
console.log('[dialogGetMountPlugin]')
const currentPlatform = platform()
if (currentPlatform === 'windows') {
// download winfsp
const wantsDownload = await ask(
'WinFsp is required on Windows to mount remotes. You can continue the operation once you\'re done with the installation.\n\nIf you still see this message, download the WinFsp installer from Github and make sure you toggle "FUSE for Cygwin" during the installation process.',
{
title: 'WinFsp not installed',
kind: 'warning',
okLabel: 'Download',
cancelLabel: 'Cancel',
}
)
if (wantsDownload) {
const winFspInstallerUrl =
'https://github.com/winfsp/winfsp/releases/download/v2.1/winfsp-2.1.25156.msi'
const localPath = `${await downloadDir()}/winfsp-installer.msi`
const installer = await (await fetch(winFspInstallerUrl)).arrayBuffer()
await writeFile(localPath, new Uint8Array(installer))
await revealItemInDir(localPath)
}
}
}