copy files
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user