From 48afc99d05c7bcd54231f340635f5102a03fbda4 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 2 Jun 2023 16:31:02 +0200 Subject: Updated 7 files, added error.php and deleted 39 files (automated) --- includes/external/chvfs/index.js | 107 --------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 includes/external/chvfs/index.js (limited to 'includes/external/chvfs/index.js') diff --git a/includes/external/chvfs/index.js b/includes/external/chvfs/index.js deleted file mode 100644 index fda57bf..0000000 --- a/includes/external/chvfs/index.js +++ /dev/null @@ -1,107 +0,0 @@ -let active = true; -let queue = []; - -const watch = require('node-watch'); -const child_process = require('child_process'); -const fs = require('fs').promises; -const fss = require('fs'); -const path = require('path'); - -process.on('uncaughtException', (e) => { - console.error(e); -}); - -function start() { - console.log("Mounting chvfs..."); - child_process.execSync("mount -t tmpfs -o size=1G chvfs /_ch"); - console.log("Mounted chvfs to /_ch"); - - console.log("Preparing filesystem..."); - child_process.execSync("cp -r /opt/peh_save/* /_ch"); - child_process.execSync("chmod -Rf 777 /_ch"); - console.log("Filesystem is ready"); - - console.log("Watching for changes..."); - watch("/_ch", { recursive: true }, (event, filename) => { - try { - if (!active || !filename) return; - - if (event === "update") { - console.log(filename + " was created or affected"); - - queue.push({ - file: filename, - remove: false - }); - } else if (event === "remove") { - console.log(filename + " was dropped"); - - queue.push({ - file: filename, - remove: true - }); - } - } catch (e) { - console.error(e); - } - }) -} - -function stop() { - active = false; - - console.log("Unmounting chvfs..."); - child_process.execSync("umount -l /_ch"); - console.log("Unmounted chvfs"); -} - -start(); -setInterval(async () => { - for (let item of queue) { - try { - if (item.remove) { - console.log("Dropping " + item.file); - await fs.unlink("/opt/peh_save/" + item.file.substring(5)); - } else { - console.log("Copying " + item.file); - try { await fs.mkdir(path.dirname(item.file), { recursive: true }); } catch (e) {} - await fs.copyFile(item.file, "/opt/peh_save/" + item.file.substring(5)); - } - } catch (e) { - console.error(e); - } - - queue.splice(0, 1); - } -}); - -process.on('exit', () => { - process.stdout.write("\n"); - - for (let item of queue) { - try { - if (item.remove) { - console.log("Dropping " + item.file); - fss.unlinkSync("/opt/peh_save/" + item.file.substring(5)); - } else { - console.log("Copying " + item.file); - try { fss.mkdirSync(path.dirname(item.file), { recursive: true }); } catch (e) {} - fss.copyFileSync(item.file, "/opt/peh_save/" + item.file.substring(5)); - } - } catch (e) { - console.error(e); - } - - queue.splice(0, 1); - } - - stop(); -}); - -process.on('SIGINT', () => { - process.exit(); -}); - -process.on('SIGTERM', () => { - process.exit(); -}); \ No newline at end of file -- cgit