summaryrefslogtreecommitdiffstats
path: root/system/application/controllers
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-07-11 20:43:27 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-07-11 20:43:27 +0200
commitfb01797274be73ac10124b2f728f7092307e6c37 (patch)
tree7b85bba0973a8b20ed9bbe8796083597ae98ce15 /system/application/controllers
parent9323029d51f2012b8193a422ab0180436dd8ce8c (diff)
allow small files to be excluded from deletion
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application/controllers')
-rw-r--r--system/application/controllers/file.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/system/application/controllers/file.php b/system/application/controllers/file.php
index d772a3478..a07debc40 100644
--- a/system/application/controllers/file.php
+++ b/system/application/controllers/file.php
@@ -131,16 +131,24 @@ class File extends Controller {
function cron()
{
$oldest_time = (time()-$this->config->item('upload_max_age'));
+ $small_upload_size = $this->config->item('small_upload_size');
$query = $this->db->query('SELECT hash, id FROM files WHERE date < ?',
array($oldest_time));
foreach($query->result_array() as $row) {
$file = $this->file_mod->file($row['hash']);
- if(file_exists($file) && filemtime($file) < $oldest_time) {
- unlink($file);
- $this->db->query('DELETE FROM files WHERE hash = ?', array($row['hash']));
- } else {
+ if (!file_exists($file)) {
$this->db->query('DELETE FROM files WHERE id = ? LIMIT 1', array($row['id']));
+ continue;
+ }
+
+ if (filesize($file) > $small_upload_size) {
+ if (filemtime($file) < $oldest_time) {
+ unlink($file);
+ $this->db->query('DELETE FROM files WHERE hash = ?', array($row['hash']));
+ } else {
+ $this->db->query('DELETE FROM files WHERE id = ? LIMIT 1', array($row['id']));
+ }
}
}
}