MUI update

This commit is contained in:
2022-05-06 00:49:23 +02:00
parent 053bb884d4
commit 018b208835
18 changed files with 1726 additions and 680 deletions

View File

@@ -46,7 +46,6 @@ export async function download(socket: Socket, payload: IPayload) {
const p = new Process(url, params, settings);
p.start().then(downloader => {
pool.add(p)
let infoLock = true;
let pid = downloader.getPid();
@@ -91,7 +90,7 @@ export async function download(socket: Socket, payload: IPayload) {
* @param {Socket} socket current connection socket
* @returns
*/
export async function retriveDownload(socket: Socket) {
export async function retrieveDownload(socket: Socket) {
// it's a cold restart: the server has just been started with pending
// downloads, so fetch them from the database and resume.
if (coldRestart) {
@@ -110,7 +109,9 @@ export async function retriveDownload(socket: Socket) {
// it's an hot-reload the server it's running and the frontend ask for
// the pending job: retrieve them from the "in-memory database" (ProcessPool)
log.info('dl', `Retrieving ${pool.size()} jobs from pool`)
const _poolSize = pool.size()
log.info('dl', `Retrieving ${_poolSize} jobs from pool`)
socket.emit('pending-jobs', _poolSize)
const it = pool.iterator();
const tempWorkQueue = new Array();
@@ -169,6 +170,13 @@ export function abortAllDownloads(socket: Socket) {
});
}
/**
* Get pool current size
*/
export function getQueueSize(): number {
return pool.size();
}
/**
* @private Formats the yt-dlp stdout to a frontend-readable format
* @param {string} stdout stdout as string

View File

@@ -2,8 +2,8 @@ import { logger, splash } from './utils/logger';
import { join } from 'path';
import { Server } from 'socket.io';
import { ytdlpUpdater } from './utils/updater';
import { download, abortDownload, retriveDownload, abortAllDownloads } from './core/downloader';
import { retrieveAll, init } from './db/db';
import { download, abortDownload, retrieveDownload, abortAllDownloads } from './core/downloader';
import { init } from './db/db';
import { getFreeDiskSpace } from './utils/procUtils';
import Logger from './utils/BetterLogger';
import Jean from './core/HTTPServer';
@@ -36,11 +36,8 @@ io.on('connection', socket => {
socket.on('update-bin', () => {
ytdlpUpdater(socket)
})
socket.on('fetch-jobs', () => {
socket.emit('pending-jobs', retrieveAll())
})
socket.on('retrieve-jobs', () => {
retriveDownload(socket)
retrieveDownload(socket)
})
socket.on('disk-space', () => {
getFreeDiskSpace(socket)