summaryrefslogtreecommitdiffstats
path: root/application/controllers/file.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-05-21 16:01:27 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-21 18:43:13 +0200
commit4dbd81cbdea371b98c1195bfb46d4ec60a4dd82c (patch)
tree875737277c0cbca8b83e88a4296e897d5f9d5e66 /application/controllers/file.php
parentfa8e83866c4c5d016cf3d1ba838773aaaa80e1ec (diff)
\c\file::clean_stale_files: Increase robustness
Delete files not matching our pattern and be forgiving if directories are cleaned up by mfile->delete_data_id. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r--application/controllers/file.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index a653d8e74..41a2c4908 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -1063,7 +1063,12 @@ class File extends MY_Controller {
continue;
}
- list($hash, $storage_id) = explode("-", $file);
+ try {
+ list($hash, $storage_id) = explode("-", $file);
+ } catch (\ErrorException $e) {
+ unlink($upload_path."/".$dir."/".$file);
+ continue;
+ }
$query = $this->db->select('hash, id')
->from('file_storage')
@@ -1074,7 +1079,6 @@ class File extends MY_Controller {
if (empty($query)) {
$this->mfile->delete_data_id($file);
- unlink($upload_path."/".$dir."/".$file);
} else {
$empty = false;
}
@@ -1082,7 +1086,7 @@ class File extends MY_Controller {
closedir($dh);
- if ($empty) {
+ if ($empty && file_exists($upload_path."/".$dir)) {
rmdir($upload_path."/".$dir);
}
}