Code cleanup

This commit is contained in:
RemixDev 2022-08-19 18:18:26 +02:00
parent aee2446d55
commit 1cce5db269
No known key found for this signature in database
GPG key ID: B33962B465BDB51C

View file

@ -700,18 +700,13 @@ class Downloader {
try { try {
if (this.settings.executeCommand !== "") { if (this.settings.executeCommand !== "") {
const child = exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.downloadObject.extrasPath)).replaceAll("%filename%", shellEscape(track.filename)), const child = exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.downloadObject.extrasPath)).replaceAll("%filename%", shellEscape(track.filename)),
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) this.afterDownloadErrorReport("ExecuteCommand", error)
this.afterDownloadErrorReport("ExecuteCommand", error) const itemData = { stderr, stdout }
} if (stderr) this.log(itemData, "stderr")
const itemData = { stderr, stdout }; if (stdout) this.log(itemData, "stdout")
if (stderr) { }
this.log(itemData, "stderr") )
}
if (stdout) {
this.log(itemData, "stdout")
}
})
await new Promise((resolve) => { await new Promise((resolve) => {
child.on('close', resolve) child.on('close', resolve)
@ -806,18 +801,13 @@ class Downloader {
try{ try{
if (this.settings.executeCommand !== "") { if (this.settings.executeCommand !== "") {
const child = exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.downloadObject.extrasPath)).replaceAll("%filename%", ''), const child = exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.downloadObject.extrasPath)).replaceAll("%filename%", ''),
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) this.afterDownloadErrorReport("ExecuteCommand", error)
this.afterDownloadErrorReport("ExecuteCommand", error) const itemData = { stderr, stdout }
} if (stderr) this.log(itemData, "stderr")
const itemData = { stderr, stdout }; if (stdout) this.log(itemData, "stdout")
if (stderr) { }
this.log(itemData, "stderr") )
}
if (stdout) {
this.log(itemData, "stdout")
}
})
await new Promise((resolve) => { await new Promise((resolve) => {
child.on('close', resolve) child.on('close', resolve)