diff --git a/client/src/modules/packageinstaller.js b/client/src/modules/packageinstaller.js index 4375bfc6..2e0e5fb3 100644 --- a/client/src/modules/packageinstaller.js +++ b/client/src/modules/packageinstaller.js @@ -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 */ diff --git a/client/src/ui/components/bd/modals/RemoteInstallModal.vue b/client/src/ui/components/bd/modals/RemoteInstallModal.vue index 209f9dd2..17fa697b 100644 --- a/client/src/ui/components/bd/modals/RemoteInstallModal.vue +++ b/client/src/ui/components/bd/modals/RemoteInstallModal.vue @@ -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(); }