Fix issue #14 and bump react to v18
This commit is contained in:
@@ -93,7 +93,7 @@ io.on('connection', socket => {
|
||||
retrieveDownload(socket)
|
||||
})
|
||||
socket.on('disk-space', () => {
|
||||
getFreeDiskSpace(socket)
|
||||
getFreeDiskSpace(socket, settings.download_path || 'downloads/')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { exec, spawn } from 'child_process';
|
||||
import { statSync } from 'fs';
|
||||
import Logger from './BetterLogger';
|
||||
// import net = require('net');
|
||||
|
||||
const log = Logger.instance;
|
||||
|
||||
@@ -18,19 +17,6 @@ export function existsInProc(pid: number): any {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function retriveStdoutFromProcFd(pid) {
|
||||
if (existsInProc(pid)) {
|
||||
const unixSocket = fs.readlinkSync(`/proc/${pid}/fd/1`).replace('socket:[', '127.0.0.1:').replace(']', '')
|
||||
if (unixSocket) {
|
||||
console.log(unixSocket)
|
||||
logger('proc', `found pending job on pid: ${pid} attached to UNIX socket: ${unixSocket}`)
|
||||
return net.createConnection(unixSocket)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Kills a process with a sys-call
|
||||
* @param {number} pid the killed process pid
|
||||
@@ -42,9 +28,9 @@ export async function killProcess(pid: number) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getFreeDiskSpace(socket: any) {
|
||||
export function getFreeDiskSpace(socket: any, path: string) {
|
||||
const message: string = 'free-space';
|
||||
exec("df -P -h | tail -1 | awk '{print $4}'", (_, stdout) => {
|
||||
exec(`df -h ${path} | tail -1 | awk '{print $4}'`, (_, stdout) => {
|
||||
socket.emit(message, stdout)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user