Removing old windows files after update

pull/253/head
aandrew-me 1 year ago
parent 9529493412
commit 2ff34e98b6

@ -53,7 +53,32 @@ function createWindow() {
win.loadFile("html/index.html"); win.loadFile("html/index.html");
// win.setMenu(null) // win.setMenu(null)
win.show(); win.show();
autoUpdater.checkForUpdates();
autoUpdater.checkForUpdates().then(result => {
// Removing unnecesary files for windows
if (result && process.platform === "win32") {
if (result.updateInfo.version === app.getVersion()) {
fs.readdir(path.join(process.env.LOCALAPPDATA, "ytdownloader-updater"), {encoding: "utf-8", withFileTypes: true}, (err, files) => {
if (err) {
console.log("No update directory to clear")
} else {
files.forEach(file => {
if (file.isFile()) {
fs.rm(path.join(file.path, file.name), (_err) => {
console.log("Removed file:", file.name)
})
} else {
fs.rm(path.join(file.path, file.name), { recursive: true}, (err) => {
console.log("Removed directory:", file.name)
})
}
})
}
})
}
}
});
} }
let loadedLanguage; let loadedLanguage;

@ -106,7 +106,8 @@
}, },
"nsis": { "nsis": {
"allowToChangeInstallationDirectory": true, "allowToChangeInstallationDirectory": true,
"oneClick": false "oneClick": false,
"deleteAppDataOnUninstall": true
}, },
"msi": { "msi": {
"oneClick": true, "oneClick": true,

Loading…
Cancel
Save