Deprecated sqlitedb in favor of in-memory db

This commit is contained in:
2022-05-06 11:28:01 +02:00
parent fd304605d9
commit 1e5be1ea11
8 changed files with 953 additions and 3845 deletions

View File

@@ -1,7 +1,6 @@
import { spawn } from 'child_process';
import { join } from 'path';
import { Readable } from 'stream';
import { deleteDownloadByPID, insertDownload } from '../db/db';
import { ISettings } from '../interfaces/ISettings';
import Logger from '../utils/BetterLogger';
@@ -53,15 +52,6 @@ class Process {
log.info('proc', `Spawned a new process, pid: ${this.pid}`)
await insertDownload(
this.url,
this.info?.title,
this.info?.thumbnail,
null,
this.params.reduce((prev, next) => `${prev} ${next}`),
this.pid
);
return this;
}
@@ -104,9 +94,7 @@ class Process {
*/
async kill() {
spawn('kill', [String(this.pid)]).on('exit', () => {
deleteDownloadByPID(this.pid).then(() => {
log.info('db', `Deleted ${this.pid} because SIGKILL`)
})
log.info('db', `Deleted ${this.pid} because SIGKILL`)
});
}

View File

@@ -1,7 +1,6 @@
import { spawn } from 'child_process';
import { from, interval } from 'rxjs';
import { throttle } from 'rxjs/operators';
import { pruneDownloads } from '../db/db';
import { killProcess } from '../utils/procUtils';
import { Socket } from 'socket.io';
import { IPayload } from '../interfaces/IPayload';
@@ -84,6 +83,7 @@ export async function download(socket: Socket, payload: IPayload) {
}
/**
* @deprecated
* Retrieve all downloads.
* If the server has just been launched retrieve the ones saved to the database.
* If the server is running fetches them from the process pool.
@@ -95,7 +95,7 @@ export async function retrieveDownload(socket: Socket) {
// downloads, so fetch them from the database and resume.
if (coldRestart) {
coldRestart = false;
let downloads = await pruneDownloads();
let downloads = [];
// sanitize
downloads = [... new Set(downloads.filter(el => el !== undefined))];
log.info('dl', `Cold restart, retrieving ${downloads.length} jobs`)