mirror of
https://github.com/HeyPuter/puter.git
synced 2026-03-12 05:00:27 -05:00
fixing issues in copy while overwriting
This commit is contained in:
@@ -163,6 +163,7 @@ class HLCopy extends HLFilesystemOperation {
|
||||
throw APIError('cannot_copy_item_into_itself');
|
||||
}
|
||||
|
||||
let overwritten;
|
||||
if ( await dest.exists() ) {
|
||||
// condition: no overwrite behaviour specified
|
||||
if ( ! values.overwrite && ! values.dedupe_name ) {
|
||||
@@ -189,12 +190,13 @@ class HLCopy extends HLFilesystemOperation {
|
||||
dest = await parent.getChild(target_name);
|
||||
}
|
||||
else if ( values.overwrite ) {
|
||||
if ( ! await chkperm(dest.entry, options.user.id, 'rm') ) {
|
||||
if ( ! await chkperm(dest.entry, values.user.id, 'rm') ) {
|
||||
throw APIError.create('forbidden');
|
||||
}
|
||||
|
||||
// TODO: This will be LLRemove
|
||||
// TODO: what to do with parent_operation?
|
||||
overwritten = await dest.getSafeEntry();
|
||||
const hl_remove = new HLRemove();
|
||||
await hl_remove.run({
|
||||
target: dest,
|
||||
@@ -213,7 +215,10 @@ class HLCopy extends HLFilesystemOperation {
|
||||
|
||||
await this.copied.awaitStableEntry();
|
||||
const response = await this.copied.getSafeEntry({ thumbnail: true });
|
||||
return response;
|
||||
return {
|
||||
copied : response,
|
||||
overwritten
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1579,8 +1579,13 @@ window.copy_clipboard_items = async function(dest_path, dest_container_element){
|
||||
dedupeName: dest_path === path.dirname(copy_path),
|
||||
});
|
||||
|
||||
// remove overwritten item from the DOM
|
||||
if(resp[0].overwritten?.id){
|
||||
$(`.item[data-uid=${resp[0].overwritten.id}]`).removeItems();
|
||||
}
|
||||
|
||||
// copy new path for undo copy
|
||||
copied_item_paths.push(resp[0].path);
|
||||
copied_item_paths.push(resp[0].copied.path);
|
||||
|
||||
// skips next loop iteration
|
||||
break;
|
||||
@@ -1676,8 +1681,13 @@ window.copy_items = function(el_items, dest_path){
|
||||
dedupeName: dest_path === path.dirname(copy_path),
|
||||
})
|
||||
|
||||
// remove overwritten item from the DOM
|
||||
if(resp[0].overwritten?.id){
|
||||
$(`.item[data-uid=${resp.overwritten.id}]`).removeItems();
|
||||
}
|
||||
|
||||
// copy new path for undo copy
|
||||
copied_item_paths.push(resp[0].path);
|
||||
copied_item_paths.push(resp[0].copied.path);
|
||||
|
||||
// skips next loop iteration
|
||||
item_with_same_name_already_exists = false;
|
||||
|
||||
Reference in New Issue
Block a user