mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-12-15 07:40:01 +08:00
Improve file overwrite confirm
This commit is contained in:
parent
65a2664cf7
commit
a89df0266a
@ -251,14 +251,4 @@ export default class FileManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
exists(uploadDir: string, fileName: string): boolean {
|
||||
const fileSaveRelativePath = path.normalize(path.join(uploadDir, fileName));
|
||||
if (!FileManager.checkFileName(path.basename(fileName)))
|
||||
throw new Error("Access denied: Malformed file name");
|
||||
if (!this.checkPath(fileSaveRelativePath))
|
||||
throw new Error("Access denied: Invalid destination");
|
||||
const fileSaveAbsolutePath = this.toAbsolutePath(fileSaveRelativePath);
|
||||
return fs.existsSync(fileSaveAbsolutePath)
|
||||
}
|
||||
}
|
||||
|
@ -369,23 +369,19 @@ export const useFileManager = (instanceId?: string, daemonId?: string) => {
|
||||
let shouldOverwrite = false;
|
||||
|
||||
if (dataSource.value?.find((dataType) => dataType.name === file.name)) {
|
||||
var complete: (value: boolean) => void, reject: (reason?: any) => void;
|
||||
var promise: Promise<boolean> = new Promise((onComplete, onReject) => {
|
||||
complete = onComplete;
|
||||
reject = onReject;
|
||||
});
|
||||
|
||||
Modal.confirm({
|
||||
title: t("TXT_CODE_99ca8563"),
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: t("TXT_CODE_ec99ddaa") + ` ${file.name} ` + t("TXT_CODE_8bd1f5d2"),
|
||||
onOk() {
|
||||
complete(true);
|
||||
},
|
||||
onCancel() {
|
||||
complete(false);
|
||||
percentComplete.value = 0;
|
||||
}
|
||||
let promise: Promise<boolean> = new Promise((onComplete, onReject) => {
|
||||
Modal.confirm({
|
||||
title: t("TXT_CODE_99ca8563"),
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: t("TXT_CODE_ec99ddaa") + ` ${file.name} ` + t("TXT_CODE_8bd1f5d2"),
|
||||
onOk() {
|
||||
onComplete(true);
|
||||
},
|
||||
onCancel() {
|
||||
onComplete(false);
|
||||
percentComplete.value = 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
shouldOverwrite = await promise;
|
||||
|
Loading…
Reference in New Issue
Block a user