Improved Voice.delete() method work

This commit is contained in:
Observer KRypt0n_ 2022-01-03 19:43:05 +02:00
parent 4b41d46505
commit d2de083355
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA

View file

@ -8,6 +8,7 @@ import Configs from './Configs';
import Debug, { DebugThread } from './core/Debug';
import Downloader, { Stream as DownloadingStream } from './core/Downloader';
import Process from './neutralino/Process';
import promisify from './core/promisify';
declare const Neutralino;
@ -19,8 +20,6 @@ class Stream extends AbstractInstaller
}
}
export default class Voice
{
protected static readonly langs = {
@ -167,15 +166,32 @@ export default class Voice
const debugThread = new DebugThread('Voice.delete', `Deleting ${this.langs[lang]} (${lang}) voice package`);
return new Promise(async (resolve) => {
Process.run(`rm -rf "${Process.addSlashes(await constants.paths.voiceDir + '/' + this.langs[lang])}"`)
.then((process) => {
process.finish(() => {
const voiceDir = await constants.paths.voiceDir;
const pipeline = promisify({
callbacks: [
() => Neutralino.os.execCommand(`rm -rf "${Process.addSlashes(`${voiceDir}/${this.langs[lang]}`)}"`),
(): Promise<void> => new Promise(async (resolve) => {
Neutralino.os.execCommand(`rm -f "${Process.addSlashes(`${await constants.paths.gameDir}/Audio_${this.langs[lang]}_pkg_version`)}"`)
.then(() => resolve());
}),
(): Promise<void> => new Promise(async (resolve) => {
Neutralino.os.execCommand(`sed -i '/${this.langs[lang]}/d' "${Process.addSlashes(`${await constants.paths.gameDataDir}/Persistent/audio_lang_14`)}"`)
.then(() => resolve());
})
],
interval: 200,
callAtOnce: true
});
pipeline.then(() => {
debugThread.log('Voice package deleted');
resolve();
});
});
});
}
/**