Merge pull request #30 from rclone-ui/pullrequests/luciodaou/fix-mount
PRs/luciodaou/fix mount
This commit is contained in:
+12
-11
@@ -2,6 +2,7 @@ import * as Sentry from '@sentry/browser'
|
||||
import { fetch } from '@tauri-apps/plugin-http'
|
||||
import { platform } from '@tauri-apps/plugin-os'
|
||||
import { useStore } from '../store'
|
||||
import { parseRcloneOptions } from './common'
|
||||
|
||||
/* UTILS */
|
||||
const SUPPORTED_BACKENDS = [
|
||||
@@ -371,8 +372,8 @@ export async function mountRemote({
|
||||
}: {
|
||||
remotePath: string
|
||||
mountPoint: string
|
||||
mountOptions?: Record<string, string | number | boolean>
|
||||
vfsOptions?: Record<string, string | number | boolean>
|
||||
mountOptions?: Record<string, string | number | boolean | string[]>
|
||||
vfsOptions?: Record<string, string | number | boolean | string[]>
|
||||
}) {
|
||||
console.log('[mountRemote]', remotePath, mountPoint)
|
||||
|
||||
@@ -381,11 +382,11 @@ export async function mountRemote({
|
||||
options.set('mountPoint', mountPoint)
|
||||
|
||||
if (mountOptions && Object.keys(mountOptions).length > 0) {
|
||||
options.set('mountOpt', JSON.stringify(mountOptions))
|
||||
options.set('mountOpt', JSON.stringify(parseRcloneOptions(mountOptions)))
|
||||
}
|
||||
|
||||
if (vfsOptions && Object.keys(vfsOptions).length > 0) {
|
||||
options.set('vfsOpt', JSON.stringify(vfsOptions))
|
||||
options.set('vfsOpt', JSON.stringify(parseRcloneOptions(vfsOptions)))
|
||||
}
|
||||
|
||||
const r = await fetch(`http://localhost:5572/mount/mount?${options.toString()}`, {
|
||||
@@ -475,11 +476,11 @@ export async function startCopy({
|
||||
params.set('_async', 'true')
|
||||
|
||||
if (_config && Object.keys(_config).length > 0) {
|
||||
params.set('_config', JSON.stringify(_config))
|
||||
params.set('_config', JSON.stringify(parseRcloneOptions(_config)))
|
||||
}
|
||||
|
||||
if (_filter && Object.keys(_filter).length > 0) {
|
||||
params.set('_filter', JSON.stringify(_filter))
|
||||
params.set('_filter', JSON.stringify(parseRcloneOptions(_filter)))
|
||||
}
|
||||
|
||||
const r = await fetch(`http://localhost:5572/sync/copy?${params.toString()}`, {
|
||||
@@ -529,11 +530,11 @@ export async function startMove({
|
||||
params.set('_async', 'true')
|
||||
|
||||
if (_config && Object.keys(_config).length > 0) {
|
||||
params.set('_config', JSON.stringify(_config))
|
||||
params.set('_config', JSON.stringify(parseRcloneOptions(_config)))
|
||||
}
|
||||
|
||||
if (_filter && Object.keys(_filter).length > 0) {
|
||||
params.set('_filter', JSON.stringify(_filter))
|
||||
params.set('_filter', JSON.stringify(parseRcloneOptions(_filter)))
|
||||
}
|
||||
|
||||
const r = await fetch(`http://localhost:5572/sync/move?${params.toString()}`, {
|
||||
@@ -570,11 +571,11 @@ export async function startSync({
|
||||
params.set('_async', 'true')
|
||||
|
||||
if (_config && Object.keys(_config).length > 0) {
|
||||
params.set('_config', JSON.stringify(_config))
|
||||
params.set('_config', JSON.stringify(parseRcloneOptions(_config)))
|
||||
}
|
||||
|
||||
if (_filter && Object.keys(_filter).length > 0) {
|
||||
params.set('_filter', JSON.stringify(_filter))
|
||||
params.set('_filter', JSON.stringify(parseRcloneOptions(_filter)))
|
||||
}
|
||||
|
||||
const r = await fetch(`http://localhost:5572/sync/sync?${params.toString()}`, {
|
||||
@@ -610,7 +611,7 @@ export async function startDelete({
|
||||
params.set('_async', 'true')
|
||||
|
||||
if (_filter && Object.keys(_filter).length > 0) {
|
||||
params.set('_filter', JSON.stringify(_filter))
|
||||
params.set('_filter', JSON.stringify(parseRcloneOptions(_filter)))
|
||||
}
|
||||
|
||||
const r = await fetch(`http://localhost:5572/operations/delete?${params.toString()}`, {
|
||||
|
||||
@@ -147,3 +147,22 @@ export async function isInternalRcloneInstalled() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function parseRcloneOptions(options: Record<string, string | number | boolean | string[]>) {
|
||||
console.log('[parseRcloneOptions]', options)
|
||||
|
||||
const parsedOptions: Record<string, string | number | boolean | string[]> = {}
|
||||
for (const [key, value] of Object.entries(options)) {
|
||||
if (value === 'true') {
|
||||
parsedOptions[key] = true
|
||||
} else if (value === 'false') {
|
||||
parsedOptions[key] = false
|
||||
} else {
|
||||
parsedOptions[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[parseRcloneOptions] parsedOptions', parsedOptions)
|
||||
|
||||
return parsedOptions
|
||||
}
|
||||
|
||||
+9
-9
@@ -90,7 +90,7 @@ export default function Mount() {
|
||||
setJsonError(null)
|
||||
} catch (error) {
|
||||
setJsonError(step)
|
||||
console.error(`Error parsing ${step} options:`, error)
|
||||
console.error(`[Mount] Error parsing ${step} options:`, error)
|
||||
}
|
||||
}, [mountOptionsJson, vfsOptionsJson])
|
||||
|
||||
@@ -102,16 +102,16 @@ export default function Mount() {
|
||||
try {
|
||||
const needsPlugin = await needsMountPlugin()
|
||||
if (needsPlugin) {
|
||||
console.log('Mount plugin not installed')
|
||||
console.log('[Mount] Mount plugin not installed')
|
||||
await dialogGetMountPlugin()
|
||||
return
|
||||
}
|
||||
console.log('Mount plugin installed')
|
||||
console.log('[Mount] Mount plugin installed')
|
||||
|
||||
const _mountOptions = { ...mountOptions }
|
||||
|
||||
if (!('VolumeName' in _mountOptions) && ['windows', 'macos'].includes(platform())) {
|
||||
_mountOptions.VolumeName = source!.split(sep()).pop()!
|
||||
_mountOptions.VolumeName = `${source.split(sep()).pop()}${Math.random().toString(36).substring(2, 3).toUpperCase()}`
|
||||
}
|
||||
|
||||
let directoryExists: boolean | undefined
|
||||
@@ -119,9 +119,9 @@ export default function Mount() {
|
||||
try {
|
||||
directoryExists = await exists(dest)
|
||||
} catch (err) {
|
||||
console.error('Error checking if directory exists:', err)
|
||||
console.error('[Mount] Error checking if directory exists:', err)
|
||||
}
|
||||
console.log('directoryExists', directoryExists)
|
||||
console.log('[Mount] directoryExists', directoryExists)
|
||||
|
||||
const isPlatformWindows = platform() === 'windows'
|
||||
|
||||
@@ -145,7 +145,7 @@ export default function Mount() {
|
||||
try {
|
||||
await mkdir(dest)
|
||||
} catch (error) {
|
||||
console.error('Error creating directory:', error)
|
||||
console.error('[Mount] Error creating directory:', error)
|
||||
await message(
|
||||
'Failed to create mount directory. Try creating it manually first.',
|
||||
{
|
||||
@@ -166,7 +166,7 @@ export default function Mount() {
|
||||
|
||||
setIsMounted(true)
|
||||
} catch (err) {
|
||||
console.error('Failed to start mount:', err)
|
||||
console.error('[Mount] Failed to start mount:', err)
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : 'Failed to start mount operation'
|
||||
await message(errorMessage, {
|
||||
@@ -288,7 +288,7 @@ export default function Mount() {
|
||||
try {
|
||||
await openPath(dest)
|
||||
} catch (err) {
|
||||
console.error('Error opening path:', err)
|
||||
console.error('[Mount] Error opening path:', err)
|
||||
await message(`Failed to open ${dest} (${err})`, {
|
||||
title: 'Open Error',
|
||||
kind: 'error',
|
||||
|
||||
Reference in New Issue
Block a user