fix: Move and Copy file conflict check race condition

This commit is contained in:
jagadam97 2025-07-07 05:19:55 +05:30
parent b28952cb25
commit e35c7737c2
2 changed files with 36 additions and 36 deletions

View File

@ -80,7 +80,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useLayoutStore, ["showHover", "closeHovers"]), ...mapActions(useLayoutStore, ["showHover", "closeHovers"]),
copy: async function (event) { copy: function (event) {
event.preventDefault(); event.preventDefault();
const items = []; const items = [];
@ -122,12 +122,11 @@ export default {
return; return;
} }
const dstItems = (await api.fetch(this.dest)).items;
const conflict = upload.checkConflict(items, dstItems);
let overwrite = false; let overwrite = false;
let rename = false; let rename = false;
api.fetch(this.dest).then((dst) => {
const conflict = upload.checkConflict(items, dst.items);
if (conflict) { if (conflict) {
this.showHover({ this.showHover({
prompt: "replace-rename", prompt: "replace-rename",
@ -145,6 +144,7 @@ export default {
} }
action(overwrite, rename); action(overwrite, rename);
});
}, },
}, },
}; };

View File

@ -85,7 +85,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useLayoutStore, ["showHover", "closeHovers"]), ...mapActions(useLayoutStore, ["showHover", "closeHovers"]),
move: async function (event) { move: function (event) {
event.preventDefault(); event.preventDefault();
const items = []; const items = [];
@ -112,12 +112,11 @@ export default {
}); });
}; };
const dstItems = (await api.fetch(this.dest)).items;
const conflict = upload.checkConflict(items, dstItems);
let overwrite = false; let overwrite = false;
let rename = false; let rename = false;
api.fetch(this.dest).then((dst) => {
const conflict = upload.checkConflict(items, dst.items);
if (conflict) { if (conflict) {
this.showHover({ this.showHover({
prompt: "replace-rename", prompt: "replace-rename",
@ -135,6 +134,7 @@ export default {
} }
action(overwrite, rename); action(overwrite, rename);
});
}, },
}, },
}; };