Delete package from temp on cancel
This commit is contained in:
parent
8078af6937
commit
5784387153
|
@ -6,7 +6,7 @@ import rimraf from 'rimraf';
|
|||
|
||||
import { request } from 'vendor';
|
||||
import { Modals } from 'ui';
|
||||
import { Utils } from 'common';
|
||||
import { Utils, FileUtils } from 'common';
|
||||
import PluginManager from './pluginmanager';
|
||||
import Globals from './globals';
|
||||
import Security from './security';
|
||||
|
@ -45,7 +45,7 @@ export default class PackageInstaller {
|
|||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
await FileUtils.deleteFile(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,15 @@ export default class PackageInstaller {
|
|||
}
|
||||
}
|
||||
|
||||
static async clearTemp(info) {
|
||||
if (!info || !info.outputPath) return;
|
||||
try {
|
||||
await FileUtils.deleteFile(info.outputPath);
|
||||
} catch (err) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches Discord upload area for .bd files
|
||||
*/
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
upToDate: true,
|
||||
allowUnsafe: Settings.getSetting('security', 'default', 'unsafe-content').value,
|
||||
installed: false,
|
||||
err: null
|
||||
err: null,
|
||||
closeHandler: null,
|
||||
closed: false
|
||||
}
|
||||
},
|
||||
props: ['modal'],
|
||||
|
@ -40,6 +42,10 @@
|
|||
async loadRemote() {
|
||||
try {
|
||||
const info = await PackageInstaller.downloadRemotePackage(this.modal.remoteLocation);
|
||||
if (this.closed) {
|
||||
PackageInstaller.clearTemp(info);
|
||||
return;
|
||||
}
|
||||
this.modal.confirm(info.outputPath);
|
||||
this.modal.close();
|
||||
} catch (err) {
|
||||
|
@ -47,6 +53,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.modal.on('close', this.closeHandler = force => {
|
||||
this.closed = true;
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
this.loadRemote();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue