Refactoring and small optimizations

This commit is contained in:
2022-01-30 12:18:36 +01:00
parent 9dcfade3fd
commit 33d567aaed
10 changed files with 91 additions and 34 deletions

View File

@@ -52,7 +52,14 @@ class Process {
log.info('proc', `Spawned a new process, pid: ${this.pid}`)
await insertDownload(this.url, this.info?.title, this.info?.thumbnail, null, this.pid);
await insertDownload(
this.url,
this.info?.title,
this.info?.thumbnail,
null,
this.params.reduce((prev, next) => `${prev} ${next}`),
this.pid
);
return this;
}

View File

@@ -95,7 +95,9 @@ export async function retriveDownload(socket: Socket) {
if (coldRestart) {
coldRestart = false;
let downloads = await pruneDownloads();
downloads = [... new Set(downloads)];
console.log(downloads)
// sanitize
downloads = [... new Set(downloads.filter(el => el !== undefined))];
log.info('dl', `Cold restart, retrieving ${downloads.length} jobs`)
for (const entry of downloads) {
if (entry) {
@@ -180,7 +182,7 @@ const formatter = (stdout: string, pid: number) => {
switch (status) {
case 'download':
return {
status: cleanStdout[0].replace(/\[|\]|\r/g, ''),
status: 'download',
progress: cleanStdout[1],
size: cleanStdout[3],
dlSpeed: cleanStdout[5],