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

This commit is contained in:
Ariel Leyva authored and GitHub committed 2026-02-27 14:55:49 +01:00
1 parent e3d00d591b
commit aa809096eb
13 files changed
+550 -154

No files matched your search

+25 -12
View File
@@ -178,6 +178,10 @@ const drop = async (event: Event) => {
from: fileStore.req?.items[i].url,
to: props.url + encodeURIComponent(fileStore.req?.items[i].name),
name: fileStore.req?.items[i].name,
size: fileStore.req?.items[i].size,
modified: fileStore.req?.items[i].modified,
overwrite: false,
rename: false,
});
}
}
@@ -189,7 +193,7 @@ const drop = async (event: Event) => {
const path = el.__vue__.url;
const baseItems = (await api.fetch(path)).items;
const action = (overwrite: boolean, rename: boolean) => {
const action = (overwrite?: boolean, rename?: boolean) => {
api
.move(items, overwrite, rename)
.then(() => {
@@ -200,26 +204,35 @@ const drop = async (event: Event) => {
const conflict = upload.checkConflict(items, baseItems);
let overwrite = false;
let rename = false;
if (conflict) {
if (conflict.length > 0) {
layoutStore.showHover({
prompt: "replace-rename",
confirm: (event: Event, option: any) => {
overwrite = option == "overwrite";
rename = option == "rename";
prompt: "resolve-conflict",
props: {
conflict: conflict,
},
confirm: (event: Event, result: Array<ConflictingResource>) => {
event.preventDefault();
layoutStore.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);
};
const itemClick = (event: Event | KeyboardEvent) => {