diff options
Diffstat (limited to 'application/controllers')
-rw-r--r-- | application/controllers/Main.php | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/application/controllers/Main.php b/application/controllers/Main.php index f48596b56..6389b1039 100644 --- a/application/controllers/Main.php +++ b/application/controllers/Main.php @@ -832,23 +832,7 @@ class Main extends MY_Controller { { $this->_require_cli_request(); - $tarball_dir = $this->config->item("upload_path")."/special/multipaste-tarballs"; - if (is_dir($tarball_dir)) { - $tarball_cache_time = $this->config->item("tarball_cache_time"); - $it = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($tarball_dir), RecursiveIteratorIterator::SELF_FIRST); - - foreach ($it as $file) { - if ($file->isFile()) { - if ($file->getMTime() < time() - $tarball_cache_time) { - $lock = fopen($file, "r+"); - flock($lock, LOCK_EX); - unlink($file); - flock($lock, LOCK_UN); - } - } - } - } + $this->clean_multipaste_tarballs(); $oldest_time = (time() - $this->config->item('upload_max_age')); $oldest_session_time = (time() - $this->config->item("sess_expiration")); @@ -885,6 +869,27 @@ class Main extends MY_Controller { } } + private function clean_multipaste_tarballs() + { + $tarball_dir = $this->config->item("upload_path")."/special/multipaste-tarballs"; + if (is_dir($tarball_dir)) { + $tarball_cache_time = $this->config->item("tarball_cache_time"); + $it = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($tarball_dir), RecursiveIteratorIterator::SELF_FIRST); + + foreach ($it as $file) { + if ($file->isFile()) { + if ($file->getMTime() < time() - $tarball_cache_time) { + $lock = fopen($file, "r+"); + flock($lock, LOCK_EX); + unlink($file); + flock($lock, LOCK_UN); + } + } + } + } + } + /* remove files without database entries */ function clean_stale_files() { |