mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-19 05:45:01 -04:00
Fix: Improve rename functionality and error handling
Co-authored-by: ijamespine <ijamespine@me.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! File rename action handler
|
||||
|
||||
use super::input::FileRenameInput;
|
||||
use super::validation::{validate_filename, FilenameValidationError};
|
||||
use super::validation::validate_filename;
|
||||
use crate::{
|
||||
context::CoreContext,
|
||||
domain::addressing::SdPath,
|
||||
|
||||
@@ -223,15 +223,15 @@ impl VolumeBackend for LocalBackend {
|
||||
recursive
|
||||
);
|
||||
|
||||
if recursive {
|
||||
fs::create_dir_all(&full_path)
|
||||
.await
|
||||
.map_err(|e| VolumeError::Io(e))?;
|
||||
} else {
|
||||
fs::create_dir(&full_path)
|
||||
.await
|
||||
.map_err(|e| VolumeError::Io(e))?;
|
||||
}
|
||||
if recursive {
|
||||
fs::create_dir_all(&full_path)
|
||||
.await
|
||||
.map_err(VolumeError::Io)?;
|
||||
} else {
|
||||
fs::create_dir(&full_path)
|
||||
.await
|
||||
.map_err(VolumeError::Io)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import clsx from "clsx";
|
||||
|
||||
interface InlineNameEditProps {
|
||||
file: File;
|
||||
onSave: (newName: string) => void;
|
||||
onSave: (newName: string) => Promise<void>;
|
||||
onCancel: () => void;
|
||||
className?: string;
|
||||
}
|
||||
@@ -55,13 +55,13 @@ export function InlineNameEdit({ file, onSave, onCancel, className }: InlineName
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSaving(true);
|
||||
try {
|
||||
onSave(fullNewName);
|
||||
} catch (error) {
|
||||
setIsSaving(false);
|
||||
// Keep in edit mode on error - let parent handle error display
|
||||
}
|
||||
setIsSaving(true);
|
||||
try {
|
||||
await onSave(fullNewName);
|
||||
} catch (error) {
|
||||
setIsSaving(false);
|
||||
// Keep in edit mode on error - let parent handle error display
|
||||
}
|
||||
}, [value, isSaving, hasExtension, file.extension, file.name, onSave, onCancel]);
|
||||
|
||||
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
||||
|
||||
@@ -128,15 +128,15 @@ export function useExplorerKeyboard() {
|
||||
{ enabled: clipboard.hasClipboard() && !!currentPath },
|
||||
);
|
||||
|
||||
// Rename: Enter key triggers rename mode when single file selected
|
||||
// Rename: Enter key triggers rename mode when single file selected (not directories)
|
||||
useKeybind(
|
||||
"explorer.renameFile",
|
||||
() => {
|
||||
if (selectedFiles.length === 1 && !isRenaming) {
|
||||
if (selectedFiles.length === 1 && !isRenaming && selectedFiles[0].kind !== "Directory") {
|
||||
startRename(selectedFiles[0].id);
|
||||
}
|
||||
},
|
||||
{ enabled: selectedFiles.length === 1 && !isRenaming },
|
||||
{ enabled: selectedFiles.length === 1 && !isRenaming && selectedFiles[0]?.kind !== "Directory" },
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user