copy files

This commit is contained in:
2025-07-30 23:35:30 +02:00
parent 956c0c6f65
commit ea09b9c470
21 changed files with 552 additions and 46 deletions

View File

@@ -1,4 +1,4 @@
import { moveFile } from '~/lib/api/warrens';
import { copyFile, moveFile } from '~/lib/api/warrens';
import type { DirectoryEntry } from '~/shared/types';
export function joinPaths(path: string, ...other: string[]): string {
@@ -58,3 +58,20 @@ export function onDirectoryEntryDrop(
await moveFile(warrenStore.current.warrenId, currentPath, targetPath);
};
}
export async function pasteFile(
current: { warrenId: string; path: string; name: string },
target: { warrenId: string; path: string; name: string }
): Promise<boolean> {
if (current.warrenId !== target.warrenId) {
throw new Error('Cross-warren copies are not supported yet');
}
const { success } = await copyFile(
current.warrenId,
joinPaths(current.path, current.name),
joinPaths(target.path, target.name)
);
return success;
}