Remove file from application data when user cancel download a model
This commit is contained in:
parent
41003861f8
commit
52b96e69a5
@ -396,7 +396,20 @@ function handleIPCs() {
|
|||||||
ipcMain.handle("abortDownload", async (_event, fileName) => {
|
ipcMain.handle("abortDownload", async (_event, fileName) => {
|
||||||
const rq = networkRequests[fileName];
|
const rq = networkRequests[fileName];
|
||||||
networkRequests[fileName] = undefined;
|
networkRequests[fileName] = undefined;
|
||||||
|
const userDataPath = app.getPath("userData");
|
||||||
|
const fullPath = join(userDataPath, fileName);
|
||||||
rq?.abort();
|
rq?.abort();
|
||||||
|
let result = "NULL";
|
||||||
|
unlink(fullPath, function (err) {
|
||||||
|
if (err && err.code == "ENOENT") {
|
||||||
|
result = `File not exist: ${err}`;
|
||||||
|
} else if (err) {
|
||||||
|
result = `File delete error: ${err}`;
|
||||||
|
} else {
|
||||||
|
result = "File deleted successfully";
|
||||||
|
}
|
||||||
|
console.log(`Delete file ${fileName} from ${fullPath} result: ${result}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user