diff --git a/lib/rclone/init.ts b/lib/rclone/init.ts index 49b6ea6..0b29108 100644 --- a/lib/rclone/init.ts +++ b/lib/rclone/init.ts @@ -94,7 +94,7 @@ export async function provisionRclone() { console.log('currentOs', currentOs) let tempDirPath = await tempDir() - if (tempDirPath.endsWith('/')) { + if (tempDirPath.endsWith('/') || tempDirPath.endsWith('\\')) { tempDirPath = tempDirPath.slice(0, -1) } console.log('tempDirPath', tempDirPath) @@ -176,6 +176,7 @@ export async function provisionRclone() { const binaryName = currentPlatform === 'windows' ? 'rclone.exe' : 'rclone' + // "/" here looks to be working on windows const rcloneBinaryPath = unarchivedPath + '/' + binaryName console.log('rcloneBinaryPath', rcloneBinaryPath) diff --git a/src/components/PathFinder.tsx b/src/components/PathFinder.tsx index 29bb838..434d7e4 100644 --- a/src/components/PathFinder.tsx +++ b/src/components/PathFinder.tsx @@ -2,6 +2,7 @@ import { Autocomplete } from '@nextui-org/autocomplete' import { AutocompleteItem, Button } from '@nextui-org/react' import { open } from '@tauri-apps/plugin-dialog' import { readDir } from '@tauri-apps/plugin-fs' +import { platform } from '@tauri-apps/plugin-os' import { ArrowDownUp, FolderOpen } from 'lucide-react' import { useCallback, useEffect, useState } from 'react' import { isRemotePath } from '../../lib/fs' @@ -119,6 +120,8 @@ export default function PathFinder({ // console.log('fetching suggestions for', path, field) + const slashSymbol = platform() === 'windows' ? '\\' : '/' + try { // If path is empty, show list of remotes if (!path) { @@ -143,14 +146,14 @@ export default function PathFinder({ console.error('Failed to fetch local suggestions:', err) try { // we also retry in case the last part of the path is wrong - cleanedPath = path.split('/').slice(0, -1).join('/') + cleanedPath = path.split(slashSymbol).slice(0, -1).join(slashSymbol) localEntries = await readDir(cleanedPath) } catch (err) { console.error('Failed to fetch local suggestions (again):', err) } } - const extraSlash = cleanedPath.endsWith('/') ? '' : '/' + const extraSlash = cleanedPath.endsWith(slashSymbol) ? '' : slashSymbol const localSuggestions = localEntries .filter((entry) => !entry.isSymlink) diff --git a/src/pages/Jobs.tsx b/src/pages/Jobs.tsx index ee35bf2..6f43c8b 100644 --- a/src/pages/Jobs.tsx +++ b/src/pages/Jobs.tsx @@ -2,6 +2,7 @@ import { Card, CardBody, CardFooter, CardHeader } from '@nextui-org/card' import { Button, Chip, Divider, Progress, Spinner } from '@nextui-org/react' import { listen } from '@tauri-apps/api/event' import { ask } from '@tauri-apps/plugin-dialog' +import { platform } from '@tauri-apps/plugin-os' import { Trash2Icon } from 'lucide-react' import { useCallback, useEffect } from 'react' import { useState } from 'react' @@ -33,9 +34,12 @@ export default function Jobs() { if (!path) { return '' } + + const slashSymbol = platform() === 'windows' ? '\\' : '/' + return path.split(':')?.[1] - ? `${path.split(':')[0]}:/.../${path.split(':')[1]?.split('/').slice(-1).join('')}` - : path.split(':')?.[0]?.split('/').slice(-1).join('') + ? `${path.split(':')[0]}:${slashSymbol}...${slashSymbol}${path.split(':')[1]?.split(slashSymbol).slice(-1).join('')}` + : path.split(':')?.[0]?.split(slashSymbol).slice(-1).join('') }, []) useEffect(() => { diff --git a/src/pages/Mount.tsx b/src/pages/Mount.tsx index c145259..ec43f5d 100644 --- a/src/pages/Mount.tsx +++ b/src/pages/Mount.tsx @@ -110,7 +110,11 @@ export default function Mount() { const _mountOptions = { ...mountOptions } if (!('VolumeName' in _mountOptions) && ['windows', 'macos'].includes(platform())) { - _mountOptions.VolumeName = source!.split('/').pop()! + if (platform() === 'windows') { + _mountOptions.VolumeName = source!.split('\\').pop()! + } else { + _mountOptions.VolumeName = source!.split('/').pop()! + } } let directoryExists: boolean | undefined