summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-04-14 22:38:45 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-04-14 22:38:45 +0200
commit8df64d85859653e5fb26a78f0cdd23d47e6cbd3f (patch)
tree57853eff5747acd6364691231a07bcb0719ac57f /application/controllers
parente654a733b27f0435331dae44b31eff8ed152ebf6 (diff)
cron: Remove expired, unowned files
Unowned files expire whenever a session expires because the user won't be able to reclaim them anymore. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/file.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 152e6a011..7d165c02e 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -334,10 +334,16 @@ class File extends CI_Controller {
if ($this->config->item('upload_max_age') == 0) return;
- $oldest_time = (time()-$this->config->item('upload_max_age'));
+ $oldest_time = (time() - $this->config->item('upload_max_age'));
+ $oldest_session_time = (time() - $this->config->item("sess_expiration"));
+
$small_upload_size = $this->config->item('small_upload_size');
- $query = $this->db->query('SELECT hash, id FROM files WHERE date < ?',
- array($oldest_time));
+
+ $query = $this->db->query('
+ SELECT hash, id, user
+ FROM files
+ WHERE date < ? OR (user = 0 AND date < ?)',
+ array($oldest_time, $oldest_session_time));
foreach($query->result_array() as $row) {
$file = $this->file_mod->file($row['hash']);
@@ -346,7 +352,7 @@ class File extends CI_Controller {
continue;
}
- if (filesize($file) > $small_upload_size) {
+ if ($row["user"] == 0 || filesize($file) > $small_upload_size) {
if (filemtime($file) < $oldest_time) {
unlink($file);
$this->db->query('DELETE FROM files WHERE hash = ?', array($row['hash']));