diff --git a/resources/php/config.php b/resources/php/config.php index 02b82e9..252784c 100644 --- a/resources/php/config.php +++ b/resources/php/config.php @@ -8,6 +8,7 @@ $TEXTVIEWER = "leafpad"; $FILEMANAGER = "spacefm"; $LOCKPASSWORD = "1234"; + $TMPFOLDERSIZE = 8000; // tmp folder size check for cleanup if above 8GB used. $UNLOCKTIME = 80; // Every ~3 sec this ticks down // Ex: 3*60 == 180 sec or 3 minutes // NOTE: Split folders with :::: diff --git a/resources/php/filesystemActions.php b/resources/php/filesystemActions.php index c1e91b4..6e00849 100644 --- a/resources/php/filesystemActions.php +++ b/resources/php/filesystemActions.php @@ -141,7 +141,23 @@ function remuxVideo($FILE) { $HASHED_NAME = hash('sha256', $FILE) . '.mp4'; $EXTNSN = strtolower(pathinfo($FILE, PATHINFO_EXTENSION)); + if (!file_exists($PTH . $HASHED_NAME)) { + $io = popen('/usr/bin/du -sm ' . $PTH, 'r'); + $size = fgets($io, 4096); + $size = (int) substr($size, 0, strpos ( $size, "\t" )); + pclose ($io); + + include 'config.php'; + if ($size > $TMPFOLDERSIZE) { + + $files = glob($PTH . '*'); + foreach($files as $file){ + if(is_file($file)) + unlink($file); + } + } + if (preg_match('(mkv)', $EXTNSN) === 1) { $COMMAND = 'ffmpeg -i "' . $FILE . '" -movflags +faststart -codec copy ' . $PTH . $HASHED_NAME; shell_exec($COMMAND . " > /dev/null &");