diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-06-04 09:36:40 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-06-04 09:36:40 +0200 |
commit | 86623358f03bec638362136ff30720efa7e1be01 (patch) | |
tree | d714a4e8012d9694b0799e4a51f578fd983d2e06 | |
parent | 6b2b903ea62ad229d4d0ee993841063937bbfb08 (diff) | |
parent | 9f3fcf036c59d5bab4dc134caec815f09b8f22e4 (diff) | |
download | nextcloud-server-86623358f03bec638362136ff30720efa7e1be01.tar.gz nextcloud-server-86623358f03bec638362136ff30720efa7e1be01.zip |
Merge pull request #8849 from owncloud/trash_expire_fix
get files in trash from file cache
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index e95f1b13c37..fb23b516208 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -730,6 +730,8 @@ class Trashbin { */ private static function expire($trashbinSize, $user) { + $view = new \OC\Files\View('/' . $user . '/files_trashbin'); + // let the admin disable auto expire $autoExpire = \OC_Config::getValue('trashbin_auto_expire', true); if ($autoExpire === false) { @@ -740,19 +742,18 @@ class Trashbin { $availableSpace = self::calculateFreeSpace($trashbinSize); $size = 0; - $query = \OC_DB::prepare('SELECT `location`,`type`,`id`,`timestamp` FROM `*PREFIX*files_trash` WHERE `user`=?'); - $result = $query->execute(array($user))->fetchAll(); - $retention_obligation = \OC_Config::getValue('trashbin_retention_obligation', self::DEFAULT_RETENTION_OBLIGATION); $limit = time() - ($retention_obligation * 86400); - foreach ($result as $r) { - $timestamp = $r['timestamp']; - $filename = $r['id']; - if ($r['timestamp'] < $limit) { + $dirContent = $view->getDirectoryContent('/files'); + + foreach ($dirContent as $file) { + $timestamp = $file['mtime']; + $filename = pathinfo($file['name'], PATHINFO_FILENAME); + if ($timestamp < $limit) { $size += self::delete($filename, $timestamp); - \OC_Log::write('files_trashbin', 'remove "' . $filename . '" fom trash bin because it is older than ' . $retention_obligation, \OC_log::INFO); + \OC_Log::write('files_trashbin', 'remove "' . $filename . '" from trash bin because it is older than ' . $retention_obligation, \OC_log::INFO); } } $availableSpace += $size; |