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 { request } from 'vendor';
|
||||||
import { Modals } from 'ui';
|
import { Modals } from 'ui';
|
||||||
import { Utils } from 'common';
|
import { Utils, FileUtils } from 'common';
|
||||||
import PluginManager from './pluginmanager';
|
import PluginManager from './pluginmanager';
|
||||||
import Globals from './globals';
|
import Globals from './globals';
|
||||||
import Security from './security';
|
import Security from './security';
|
||||||
|
@ -45,7 +45,7 @@ export default class PackageInstaller {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} 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
|
* Patches Discord upload area for .bd files
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
upToDate: true,
|
upToDate: true,
|
||||||
allowUnsafe: Settings.getSetting('security', 'default', 'unsafe-content').value,
|
allowUnsafe: Settings.getSetting('security', 'default', 'unsafe-content').value,
|
||||||
installed: false,
|
installed: false,
|
||||||
err: null
|
err: null,
|
||||||
|
closeHandler: null,
|
||||||
|
closed: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: ['modal'],
|
props: ['modal'],
|
||||||
|
@ -40,6 +42,10 @@
|
||||||
async loadRemote() {
|
async loadRemote() {
|
||||||
try {
|
try {
|
||||||
const info = await PackageInstaller.downloadRemotePackage(this.modal.remoteLocation);
|
const info = await PackageInstaller.downloadRemotePackage(this.modal.remoteLocation);
|
||||||
|
if (this.closed) {
|
||||||
|
PackageInstaller.clearTemp(info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.modal.confirm(info.outputPath);
|
this.modal.confirm(info.outputPath);
|
||||||
this.modal.close();
|
this.modal.close();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -47,6 +53,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.modal.on('close', this.closeHandler = force => {
|
||||||
|
this.closed = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadRemote();
|
this.loadRemote();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue