From 423adc78e9750d82af03bcaaa6561a2d7c6bd5ed Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 11 Sep 2012 15:41:51 +0200 Subject: file/cron: always remove stale files Signed-off-by: Florian Pritz --- application/controllers/file.php | 3 +++ application/models/mfile.php | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'application') diff --git a/application/controllers/file.php b/application/controllers/file.php index 7c5918e07..c2af86fe9 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -593,6 +593,9 @@ class File extends CI_Controller { $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'])); + if ($this->mfile->stale_hash($row["hash"])) { + unlink($file); + } } } } diff --git a/application/models/mfile.php b/application/models/mfile.php index 0187f3086..97c9ecfcd 100644 --- a/application/models/mfile.php +++ b/application/models/mfile.php @@ -47,6 +47,11 @@ class Mfile extends CI_Model { } } + public function stale_hash($hash) + { + return $this->unused_file($hash); + } + function get_filedata($id) { $sql = ' -- cgit v1.2.3-24-g4f1b