feat: improved conflict resolution when uploading/copying/moving files (#5765)

This commit is contained in:
Ariel Leyva
2026-02-27 08:55:49 -05:00
committed by GitHub
parent e3d00d591b
commit aa809096eb
13 changed files with 550 additions and 154 deletions

View File

@@ -97,6 +97,10 @@ export default {
from: this.req.items[item].url,
to: this.dest + encodeURIComponent(this.req.items[item].name),
name: this.req.items[item].name,
size: this.req.items[item].size,
modified: this.req.items[item].modified,
overwrite: false,
rename: false,
});
}
@@ -121,26 +125,39 @@ export default {
const dstItems = (await api.fetch(this.dest)).items;
const conflict = upload.checkConflict(items, dstItems);
let overwrite = false;
let rename = false;
if (conflict) {
if (conflict.length > 0) {
this.showHover({
prompt: "replace-rename",
confirm: (event, option) => {
overwrite = option == "overwrite";
rename = option == "rename";
prompt: "resolve-conflict",
props: {
conflict: conflict,
files: items,
},
confirm: (event, result) => {
event.preventDefault();
this.closeHovers();
action(overwrite, rename);
for (let i = result.length - 1; i >= 0; i--) {
const item = result[i];
if (item.checked.length == 2) {
items[item.index].rename = true;
} else if (
item.checked.length == 1 &&
item.checked[0] == "origin"
) {
items[item.index].overwrite = true;
} else {
items.splice(item.index, 1);
}
}
if (items.length > 0) {
action();
}
},
});
return;
}
action(overwrite, rename);
action(false, false);
},
},
};