filemanager: ask user for confirmation on rename conflict

This commit is contained in:
Johannes Zellner
2024-01-04 15:47:26 +01:00
parent 4f57bed03a
commit c577d3d91f
2 changed files with 20 additions and 4 deletions
+18 -2
View File
@@ -378,8 +378,24 @@ export default {
},
async renameHandler(file, newName) {
await this.directoryModel.rename(this.directoryModel.buildFilePath(this.cwd, file.name), sanitize(this.cwd + '/' + newName));
await this.loadCwd();
try {
await this.directoryModel.rename(this.directoryModel.buildFilePath(this.cwd, file.name), sanitize(this.cwd + '/' + newName));
await this.loadCwd();
} catch (e) {
if (e.status === 409) {
this.$confirm.require({
message: this.$t('filemanager.renameDialog.reallyOverwrite'),
icon: '',
acceptClass: 'p-button-danger',
accept: async () => {
await this.directoryModel.rename(this.directoryModel.buildFilePath(this.cwd, file.name), sanitize(this.cwd + '/' + newName), true /* overwrite */);
await this.loadCwd();
this.$confirm.close();
}
});
}
else console.error(`Failed to rename ${file} to ${newName}`, e);
}
},
async changeOwnerHandler(files, newOwnerUid) {
if (!files) return;