aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-06-03 16:45:11 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-06-03 16:45:11 +0200
commit05cf34ea1fe2d5032dcb2857c31194432d7d443b (patch)
treef330e5788123b35734c2b2857d145bbe05597fff /apps/files_trashbin/lib
parenta5dd8e84f13c9815c0208851664238cfc0034b5b (diff)
downloadnextcloud-server-05cf34ea1fe2d5032dcb2857c31194432d7d443b.tar.gz
nextcloud-server-05cf34ea1fe2d5032dcb2857c31194432d7d443b.zip
get files in trash from file cache
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r--apps/files_trashbin/lib/trashbin.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index e95f1b13c37..b507d5f3df9 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,17 +742,16 @@ 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);
}