slash handling on windows

This commit is contained in:
FTCHD
2025-02-28 17:28:06 +02:00
parent 55d1daa1d1
commit 14c8e8650f
4 changed files with 18 additions and 6 deletions
+2 -1
View File
@@ -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)
+5 -2
View File
@@ -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)
+6 -2
View File
@@ -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(() => {
+5 -1
View File
@@ -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