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

@@ -1,6 +1,6 @@
import { spawn } from 'child_process';
import { exec, spawn } from 'child_process';
import fs = require('fs');
import net = require('net');
// import net = require('net');
import { logger } from './logger';
/**
@@ -39,3 +39,11 @@ export async function killProcess(pid: number) {
logger('proc', `Successfully killed yt-dlp process, pid: ${pid}`)
})
}
export function getFreeDiskSpace(socket: any) {
let buffer: string = '';
let message: string = 'free-space';
exec("df -h / | tail -1 | awk '{print $4}'", (_, stdout) => {
socket.emit(message, stdout)
})
}