Skip to content

Commit

Permalink
Remove file from application data when user cancel download a model
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Nov 14, 2023
1 parent 4100386 commit 52b96e6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,20 @@ function handleIPCs() {
ipcMain.handle("abortDownload", async (_event, fileName) => {
const rq = networkRequests[fileName];
networkRequests[fileName] = undefined;
const userDataPath = app.getPath("userData");
const fullPath = join(userDataPath, fileName);
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}`);
});
});

/**
Expand Down

0 comments on commit 52b96e6

Please sign in to comment.