From 686254ac1170dfd76d90b3cc6bd54761ae3d6908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 19 Feb 2013 18:45:46 +0100 Subject: [PATCH 01/19] move2trash() handles keyfiles --- apps/files_trashbin/lib/trash.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 8d54a471b42..1c0306ea90a 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -37,7 +37,9 @@ class Trashbin { $view = new \OC_FilesystemView('/'. $user); if (!$view->is_dir('files_trashbin')) { $view->mkdir('files_trashbin'); - $view->mkdir("versions_trashbin"); + $view->mkdir("files_trashbin/files"); + $view->mkdir("files_trashbin/versions"); + $view->mkdir("files_trashbin/keyfiles"); } $path_parts = pathinfo($file_path); @@ -54,31 +56,38 @@ class Trashbin { } if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { - $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); + $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); } - $trashbinSize += self::copy_recursive($file_path, 'files_trashbin/'.$deleted.'.d'.$timestamp, $view); + $trashbinSize += self::copy_recursive($file_path, 'files_trashbin/files/'.$deleted.'.d'.$timestamp, $view); - if ( $view->file_exists('files_trashbin/'.$deleted.'.d'.$timestamp) ) { + if ( $view->file_exists('files_trashbin/files/'.$deleted.'.d'.$timestamp) ) { $query = \OC_DB::prepare("INSERT INTO *PREFIX*files_trash (id,timestamp,location,type,mime,user) VALUES (?,?,?,?,?,?)"); $result = $query->execute(array($deleted, $timestamp, $location, $type, $mime, $user)); if ( !$result ) { // if file couldn't be added to the database than also don't store it in the trash bin. - $view->deleteAll('files_trashbin/'.$deleted.'.d'.$timestamp); + $view->deleteAll('files_trashbin/files/'.$deleted.'.d'.$timestamp); \OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR); return; } - + + // Take core of file versions if ( \OCP\App::isEnabled('files_versions') ) { if ( $view->is_dir('files_versions'.$file_path) ) { $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_versions/'.$file_path)); - $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp); + $view->rename('files_versions'.$file_path, 'files_trashbin/versions'. $deleted.'.d'.$timestamp); } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) { foreach ($versions as $v) { $trashbinSize += $view->filesize('files_versions'.$v['path'].'.v'.$v['version']); - $view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'versions_trashbin/'. $deleted.'.v'.$v['version'].'.d'.$timestamp); + $view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'files_trashbin/versions'. $deleted.'.v'.$v['version'].'.d'.$timestamp); } } } + + // Take care of encryption keys + if ( \OCP\App::isEnabled('files_encryption') ) { + $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_encryption/keyfiles/'.$file_path)); + $view->rename('files_encryption'.$file_path, 'files_trashbin/keyfiles'. $deleted.'.d'.$timestamp); + } + } else { \OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin', \OC_log::ERROR); } From 4d0df9614b3aed23920f99645fed7a4385034525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 20 Feb 2013 13:34:32 +0100 Subject: [PATCH 02/19] put all trash bin content in user/files_trashbin --- apps/files_trashbin/lib/trash.php | 64 +++++++++++++++---------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 1c0306ea90a..b54805c63e5 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -34,7 +34,7 @@ class Trashbin { */ public static function move2trash($file_path) { $user = \OCP\User::getUser(); - $view = new \OC_FilesystemView('/'. $user); + $view = new \OC\Files\View('/'. $user); if (!$view->is_dir('files_trashbin')) { $view->mkdir('files_trashbin'); $view->mkdir("files_trashbin/files"); @@ -87,7 +87,7 @@ class Trashbin { $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_encryption/keyfiles/'.$file_path)); $view->rename('files_encryption'.$file_path, 'files_trashbin/keyfiles'. $deleted.'.d'.$timestamp); } - + } else { \OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin', \OC_log::ERROR); } @@ -127,7 +127,6 @@ class Trashbin { if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); } if ( $timestamp ) { $query = \OC_DB::prepare('SELECT location,type FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); @@ -148,12 +147,12 @@ class Trashbin { $path_parts = pathinfo($filename); $result[] = array( 'location' => $path_parts['dirname'], - 'type' => $view->is_dir('/files_trashbin/'.$file) ? 'dir' : 'files', + 'type' => $view->is_dir('/files_trashbin/files/'.$file) ? 'dir' : 'files', ); $location = ''; } - $source = \OC_Filesystem::normalizePath('files_trashbin/'.$file); + $source = \OC_Filesystem::normalizePath('files_trashbin/files/'.$file); $target = \OC_Filesystem::normalizePath('files/'.$location.'/'.$filename); // we need a extension in case a file/dir with the same name already exists @@ -174,16 +173,16 @@ class Trashbin { $versionedFile = $file; } if ( $result[0]['type'] == 'dir' ) { - $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.'versions_trashbin/'. $file)); - $view->rename(\OC_Filesystem::normalizePath('versions_trashbin/'. $file), \OC_Filesystem::normalizePath('files_versions/'.$location.'/'.$filename.$ext)); + $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.'files_trashbin/versions/'. $file)); + $view->rename(\OC_Filesystem::normalizePath('files_trashbin/versions/'. $file), \OC_Filesystem::normalizePath('files_versions/'.$location.'/'.$filename.$ext)); } else if ( $versions = self::getVersionsFromTrash($versionedFile, $timestamp) ) { foreach ($versions as $v) { if ($timestamp ) { - $trashbinSize -= $view->filesize('versions_trashbin/'.$versionedFile.'.v'.$v.'.d'.$timestamp); - $view->rename('versions_trashbin/'.$versionedFile.'.v'.$v.'.d'.$timestamp, 'files_versions/'.$location.'/'.$filename.$ext.'.v'.$v); + $trashbinSize -= $view->filesize('files_trashbin/versions/'.$versionedFile.'.v'.$v.'.d'.$timestamp); + $view->rename('files_trashbin/versions/'.$versionedFile.'.v'.$v.'.d'.$timestamp, 'files_versions/'.$location.'/'.$filename.$ext.'.v'.$v); } else { - $trashbinSize -= $view->filesize('versions_trashbin/'.$versionedFile.'.v'.$v); - $view->rename('versions_trashbin/'.$versionedFile.'.v'.$v, 'files_versions/'.$location.'/'.$filename.$ext.'.v'.$v); + $trashbinSize -= $view->filesize('files_trashbin/versions/'.$versionedFile.'.v'.$v); + $view->rename('files_trashbin/versions/'.$versionedFile.'.v'.$v, 'files_versions/'.$location.'/'.$filename.$ext.'.v'.$v); } } } @@ -216,7 +215,6 @@ class Trashbin { if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); } if ( $timestamp ) { @@ -228,28 +226,28 @@ class Trashbin { } if ( \OCP\App::isEnabled('files_versions') ) { - if ($view->is_dir('versions_trashbin/'.$file)) { - $size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/versions_trashbin/'.$file)); - $view->unlink('versions_trashbin/'.$file); + if ($view->is_dir('files_trashbin/versions/'.$file)) { + $size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/files_trashbin/versions/'.$file)); + $view->unlink('files_trashbin/versions/'.$file); } else if ( $versions = self::getVersionsFromTrash($filename, $timestamp) ) { foreach ($versions as $v) { if ($timestamp ) { - $size += $view->filesize('/versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); - $view->unlink('/versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); } else { - $size += $view->filesize('/versions_trashbin/'.$filename.'.v'.$v); - $view->unlink('/versions_trashbin/'.$filename.'.v'.$v); + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v); + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v); } } } } - if ($view->is_dir('/files_trashbin/'.$file)) { - $size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/files_trashbin/'.$file)); + if ($view->is_dir('/files_trashbin/files/'.$file)) { + $size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/files_trashbin/files/'.$file)); } else { - $size += $view->filesize('/files_trashbin/'.$file); + $size += $view->filesize('/files_trashbin/files/'.$file); } - $view->unlink('/files_trashbin/'.$file); + $view->unlink('/files_trashbin/files/'.$file); $trashbinSize -= $size; \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize); @@ -272,7 +270,7 @@ class Trashbin { $filename = $filename; } - $target = \OC_Filesystem::normalizePath('files_trashbin/'.$filename); + $target = \OC_Filesystem::normalizePath('files_trashbin/files/'.$filename); return $view->file_exists($target); } @@ -297,19 +295,19 @@ class Trashbin { $timestamp = $r['timestamp']; $filename = $r['id']; if ( $r['timestamp'] < $limit ) { - if ($view->is_dir('files_trashbin/'.$filename.'.d'.$timestamp)) { - $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/files_trashbin/'.$filename.'.d'.$timestamp)); + if ($view->is_dir('files_trashbin/files/'.$filename.'.d'.$timestamp)) { + $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/files_trashbin/files/'.$filename.'.d'.$timestamp)); } else { - $size += $view->filesize('files_trashbin/'.$filename.'.d'.$timestamp); + $size += $view->filesize('files_trashbin/files/'.$filename.'.d'.$timestamp); } - $view->unlink('files_trashbin/'.$filename.'.d'.$timestamp); + $view->unlink('files_trashbin/files/'.$filename.'.d'.$timestamp); if ($r['type'] == 'dir') { - $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/versions_trashbin/'.$filename.'.d'.$timestamp)); - $view->unlink('versions_trashbin/'.$filename.'.d'.$timestamp); + $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/files_trashbin/versions'.$filename.'.d'.$timestamp)); + $view->unlink('files_trashbin/versions'.$filename.'.d'.$timestamp); } else if ( $versions = self::getVersionsFromTrash($filename, $timestamp) ) { foreach ($versions as $v) { - $size += $view->filesize('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); - $view->unlink('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); + $size += $view->filesize('files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); + $view->unlink('files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); } } } @@ -373,7 +371,7 @@ class Trashbin { * @param $timestamp timestamp when the file was deleted */ private static function getVersionsFromTrash($filename, $timestamp) { - $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/versions_trashbin'); + $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin/versions'); $versionsName = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($filename); $versions = array(); if ($timestamp ) { From c49e73d43cd0e775ec653fa59811381b70e3efe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 20 Feb 2013 15:14:32 +0100 Subject: [PATCH 03/19] restore filekeys from trash bin --- apps/files_trashbin/lib/trash.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index b54805c63e5..cde388015e5 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -82,10 +82,11 @@ class Trashbin { } } - // Take care of encryption keys - if ( \OCP\App::isEnabled('files_encryption') ) { - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_encryption/keyfiles/'.$file_path)); - $view->rename('files_encryption'.$file_path, 'files_trashbin/keyfiles'. $deleted.'.d'.$timestamp); + // Take care of encryption keys + $keyfile = \OC_Filesystem::normalizePath('files_encryption/keyfiles/'.$file_path.'.key'); + if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { + $trashbinSize += $view->filesize($keyfile); + $view->rename($keyfile, 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp); } } else { @@ -187,7 +188,18 @@ class Trashbin { } } } - + + // Take care of encryption keys + $keyfile = 'files_trashbin/keyfiles/'.$file; + if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { + if ( $result[0]['type'] == 'dir' ) { + $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); + } else { + $trashbinSize -= $view->filesize($keyfile); + } + $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename.'.key'); + } + if ( $timestamp ) { $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); $query->execute(array($user,$filename,$timestamp)); From 4b5a662e09e1f1d0b7885b546e7b278fe263be34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 20 Feb 2013 17:58:04 +0100 Subject: [PATCH 04/19] delete keyfiles if file in trash bin gets deleted permanently --- apps/files_trashbin/lib/trash.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index cde388015e5..5c0cf36f5b3 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -83,10 +83,14 @@ class Trashbin { } // Take care of encryption keys - $keyfile = \OC_Filesystem::normalizePath('files_encryption/keyfiles/'.$file_path.'.key'); - if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { - $trashbinSize += $view->filesize($keyfile); - $view->rename($keyfile, 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp); + $keyfile = \OC_Filesystem::normalizePath('files_encryption/keyfiles/'.$file_path); + if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile.'.key') ) { + if ( $view->is_dir('files'.$file_path) ) { + $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); + } else { + $trashbinSize += $view->filesize($keyfile.'.key'); + } + $view->rename($keyfile.'.key', 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp); } } else { @@ -190,7 +194,7 @@ class Trashbin { } // Take care of encryption keys - $keyfile = 'files_trashbin/keyfiles/'.$file; + $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$file); if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { if ( $result[0]['type'] == 'dir' ) { $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); @@ -252,6 +256,17 @@ class Trashbin { } } } + } + + // Take care of encryption keys + $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$file); + if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { + if ( $result[0]['type'] == 'dir' ) { + $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); + } else { + $size += $view->filesize($keyfile); + } + $view->unlink($keyfile); } if ($view->is_dir('/files_trashbin/files/'.$file)) { From 5ce6d1fb5774bdc7dacea4c853d5412f03004e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 20 Feb 2013 18:00:15 +0100 Subject: [PATCH 05/19] reuse delete() function in expire() --- apps/files_trashbin/lib/trash.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 5c0cf36f5b3..4d230449b59 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -322,27 +322,10 @@ class Trashbin { $timestamp = $r['timestamp']; $filename = $r['id']; if ( $r['timestamp'] < $limit ) { - if ($view->is_dir('files_trashbin/files/'.$filename.'.d'.$timestamp)) { - $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/files_trashbin/files/'.$filename.'.d'.$timestamp)); - } else { - $size += $view->filesize('files_trashbin/files/'.$filename.'.d'.$timestamp); - } - $view->unlink('files_trashbin/files/'.$filename.'.d'.$timestamp); - if ($r['type'] == 'dir') { - $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/files_trashbin/versions'.$filename.'.d'.$timestamp)); - $view->unlink('files_trashbin/versions'.$filename.'.d'.$timestamp); - } else if ( $versions = self::getVersionsFromTrash($filename, $timestamp) ) { - foreach ($versions as $v) { - $size += $view->filesize('files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); - $view->unlink('files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); - } - } + $size += self::delete($filename, $timestamp); } } - - $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND timestampexecute(array($user,$limit)); - + $availableSpace = $availableSpace + $size; // if size limit for trash bin reached, delete oldest files in trash bin if ($availableSpace < 0) { @@ -355,8 +338,7 @@ class Trashbin { $availableSpace += $tmp; $size += $tmp; $i++; - } - + } } return $size; From 5329c9ea31a1e0c31756d4faf8a9946965032012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 20 Feb 2013 19:18:34 +0100 Subject: [PATCH 06/19] update script which copies all trash bin related files to user/files_trashbin --- apps/files_trashbin/appinfo/update.php | 40 ++++++++++++++++++++++++++ apps/files_trashbin/appinfo/version | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 apps/files_trashbin/appinfo/update.php diff --git a/apps/files_trashbin/appinfo/update.php b/apps/files_trashbin/appinfo/update.php new file mode 100644 index 00000000000..b0bf79cc510 --- /dev/null +++ b/apps/files_trashbin/appinfo/update.php @@ -0,0 +1,40 @@ + Date: Wed, 20 Feb 2013 22:17:04 +0100 Subject: [PATCH 07/19] some fixes for the keyfile handling --- apps/files_trashbin/lib/trash.php | 38 +++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 4d230449b59..f11e5c4cbfd 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -69,7 +69,7 @@ class Trashbin { return; } - // Take core of file versions + // Take care of file versions if ( \OCP\App::isEnabled('files_versions') ) { if ( $view->is_dir('files_versions'.$file_path) ) { $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_versions/'.$file_path)); @@ -86,11 +86,12 @@ class Trashbin { $keyfile = \OC_Filesystem::normalizePath('files_encryption/keyfiles/'.$file_path); if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile.'.key') ) { if ( $view->is_dir('files'.$file_path) ) { - $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); + $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); + $view->rename($keyfile, 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp); } else { $trashbinSize += $view->filesize($keyfile.'.key'); + $view->rename($keyfile.'.key', 'files_trashbin/keyfiles/'. $deleted.'.key.d'.$timestamp); } - $view->rename($keyfile.'.key', 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp); } } else { @@ -149,7 +150,7 @@ class Trashbin { $location = ''; } } else { - $path_parts = pathinfo($filename); + $path_parts = pathinfo($file); $result[] = array( 'location' => $path_parts['dirname'], 'type' => $view->is_dir('/files_trashbin/files/'.$file) ? 'dir' : 'files', @@ -193,15 +194,24 @@ class Trashbin { } } - // Take care of encryption keys - $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$file); + // Take care of encryption keys TODO! Get '.key' in file between file name and delete date (also for permanent delete!) + $parts = pathinfo($file); + if ( $result[0]['type'] == 'dir' ) { + $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$parts['dirname'].'/'.$filename); + } else { + $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$parts['dirname'].'/'.$filename.'.key'); + } + if ($timestamp) { + $keyfile .= '.d'.$timestamp; + } if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { if ( $result[0]['type'] == 'dir' ) { $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); + $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename); } else { $trashbinSize -= $view->filesize($keyfile); + $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename.'.key'); } - $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename.'.key'); } if ( $timestamp ) { @@ -258,10 +268,18 @@ class Trashbin { } } - // Take care of encryption keys - $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$file); + // Take care of encryption keys + $parts = pathinfo($file); + if ( $view->is_dir('/files_trashbin/files/'.$file) ) { + $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$filename); + } else { + $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$filename.'.key'); + } + if ($timestamp) { + $keyfile .= '.d'.$timestamp; + } if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { - if ( $result[0]['type'] == 'dir' ) { + if ( $view->is_dir($keyfile) ) { $size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); } else { $size += $view->filesize($keyfile); From 2d6efae25714b188d4e689617b2e4ae8695b0317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 20 Feb 2013 22:19:23 +0100 Subject: [PATCH 08/19] update path to deleted files --- apps/files_trashbin/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index a2d4cc0a44d..8f8d143b4d1 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -9,7 +9,7 @@ OCP\Util::addScript('files', 'fileactions'); $tmpl = new OCP\Template('files_trashbin', 'index', 'user'); $user = \OCP\User::getUser(); -$view = new OC_Filesystemview('/'.$user.'/files_trashbin'); +$view = new OC_Filesystemview('/'.$user.'/files_trashbin/files'); OCP\Util::addStyle('files', 'files'); OCP\Util::addScript('files', 'filelist'); @@ -17,8 +17,7 @@ OCP\Util::addScript('files', 'filelist'); $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : ''; if ($dir) { - $dirlisting = true; - $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin'); + $dirlisting = true; $fullpath = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($dir); $dirContent = opendir($fullpath); $i = 0; From fc1fba23040908fe5629f89b66a280aea5578520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 21 Feb 2013 00:02:52 +0100 Subject: [PATCH 09/19] don't show empty trash bin message for sub folders --- apps/files_trashbin/index.php | 1 + apps/files_trashbin/templates/index.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index 8f8d143b4d1..d575c75f1a3 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -94,6 +94,7 @@ $list->assign('disableDownloadActions', true); $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false); $tmpl->assign('fileList', $list->fetchPage(), false); $tmpl->assign('files', $files); +$tmpl->assign('dirlisting', $dirlisting); $tmpl->assign('dir', OC_Filesystem::normalizePath($view->getAbsolutePath())); $tmpl->printPage(); diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index c3e51b4becd..b62ca0af00c 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -5,7 +5,7 @@
- +
t('Nothing in here. Your trash bin is empty!')?>
From 0a5457c5506730bf75a319b74a5bc97169da36d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 21 Feb 2013 14:40:16 +0100 Subject: [PATCH 10/19] fix getVersions(), we need to get the correct user and filename --- apps/files_versions/ajax/getVersions.php | 4 ++-- apps/files_versions/lib/versions.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 53fc04625c6..8a8fa43080c 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -1,11 +1,11 @@ 604800), ); - private static function getUidAndFilename($filename) { + public static function getUidAndFilename($filename) { $uid = \OC\Files\Filesystem::getOwner($filename); if ( $uid != \OCP\User::getUser() ) { $info = \OC\Files\Filesystem::getFileInfo($filename); From 859caee66a107b7e46f3d0bc615acfd112a2981d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 21 Feb 2013 16:52:18 +0100 Subject: [PATCH 11/19] use :hover pseudo class to set opacity --- apps/files/css/files.css | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index dfc2e4c0e2f..3cd809038b9 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -123,6 +123,24 @@ a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; } .selectedActions a { display:inline; margin:-.5em 0; padding:.5em !important; } .selectedActions a img { position:relative; top:.3em; } +#fileList a.action { + display:none; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: alpha(opacity=0); + opacity: 0; +} +#fileList tr:hover a.action { + display:inline; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=.5)"; + filter: alpha(opacity=.5); + opacity: .5; +} +#fileList tr:hover a.action:hover { + display:inline; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=1)"; + filter: alpha(opacity=1); + opacity: 1; +} #scanning-message{ top:40%; left:40%; position:absolute; display:none; } From 0dd7fd0599e0757abc81677ccbb8d4a6839a5f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 21 Feb 2013 17:38:25 +0100 Subject: [PATCH 12/19] IE8 does not support window.onclick --- apps/files/js/files.js | 2 +- core/js/js.js | 2 +- search/js/result.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 8327460cca6..aeb7aedfaee 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -524,7 +524,7 @@ $(document).ready(function() { crumb.text(text); } - $(window).click(function(){ + $(document).click(function(){ $('#new>ul').hide(); $('#new').removeClass('active'); $('#new li').each(function(i,element){ diff --git a/core/js/js.js b/core/js/js.js index 6d5d65403fb..e373fca8865 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -669,7 +669,7 @@ $(document).ready(function(){ $('#settings #expanddiv').click(function(event){ event.stopPropagation(); }); - $(window).click(function(){//hide the settings menu when clicking outside it + $(document).click(function(){//hide the settings menu when clicking outside it $('#settings #expanddiv').slideUp(200); }); diff --git a/search/js/result.js b/search/js/result.js index cadb0d0aabe..78fa8efc8e9 100644 --- a/search/js/result.js +++ b/search/js/result.js @@ -28,7 +28,7 @@ OC.search.showResults=function(results){ OC.search.hide(); event.stopPropagation(); }); - $(window).click(function(event){ + $(document).click(function(event){ OC.search.hide(); }); OC.search.lastResults=results; From ebcb778a99e11c4c0f13ccd6bcdf11c2a0c21bc8 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Mon, 25 Feb 2013 10:12:47 +0100 Subject: [PATCH 13/19] remove the check for session data folder - causes trouble on some environments let's try to find another solution for =C6 --- lib/util.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/util.php b/lib/util.php index 87facda1804..dd56e0308a2 100755 --- a/lib/util.php +++ b/lib/util.php @@ -275,19 +275,6 @@ class OC_Util { $web_server_restart= false; } - $handler = ini_get("session.save_handler"); - if($handler == "files") { - $tmpDir = session_save_path(); - if($tmpDir != "") { - if(!@is_writable($tmpDir)) { - $errors[]=array('error' => 'The temporary folder used by PHP to save the session data' - .' is either incorrect or not writable! Please check : '.session_save_path().'
', - 'hint'=>'Please ask your server administrator to grant write access' - .' or define another temporary folder.'); - } - } - } - if($web_server_restart) { $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?
', 'hint'=>'Please ask your server administrator to restart the web server.'); From 736d5deaeec3a7238af7bfd420c7122b321a277a Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 25 Feb 2013 11:39:32 +0100 Subject: [PATCH 14/19] version checks for apps now use all three version numbers and fixed bug that would not do the version check correctly for the second version --- lib/app.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/app.php b/lib/app.php index e653c30b2d9..a5618be84f1 100644 --- a/lib/app.php +++ b/lib/app.php @@ -223,7 +223,8 @@ class OC_App{ // check if the app is compatible with this version of ownCloud $info=OC_App::getAppInfo($app); $version=OC_Util::getVersion(); - if(!isset($info['require']) or ($version[0]>$info['require'])) { + $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); + if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { OC_Log::write('core', 'App "'.$info['name'].'" can\'t be installed because it is' .' not compatible with this version of ownCloud', @@ -851,7 +852,8 @@ class OC_App{ foreach($apps as $app) { // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); - if(!isset($info['require']) or (($version[0].'.'.$version[1])>$info['require'])) { + $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); + if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { OC_Log::write('core', 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is' .' not compatible with this version of ownCloud', From ecd40f0abc8328692df44a2b082fb2ba5dcfbbd2 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 25 Feb 2013 11:40:55 +0100 Subject: [PATCH 15/19] spaces to tabs --- lib/app.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/app.php b/lib/app.php index a5618be84f1..91bb833b0d0 100644 --- a/lib/app.php +++ b/lib/app.php @@ -223,8 +223,8 @@ class OC_App{ // check if the app is compatible with this version of ownCloud $info=OC_App::getAppInfo($app); $version=OC_Util::getVersion(); - $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); - if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { + $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); + if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { OC_Log::write('core', 'App "'.$info['name'].'" can\'t be installed because it is' .' not compatible with this version of ownCloud', @@ -852,8 +852,8 @@ class OC_App{ foreach($apps as $app) { // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); - $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); - if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { + $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); + if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { OC_Log::write('core', 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is' .' not compatible with this version of ownCloud', From 5bf3d286f02474c99dd52b2680594c9ed272f92a Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 25 Feb 2013 12:38:00 +0100 Subject: [PATCH 16/19] created unittests and factored out version test into seperate method --- lib/app.php | 36 ++++++++++++++++++++++++++++---- tests/lib/app.php | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 tests/lib/app.php diff --git a/lib/app.php b/lib/app.php index 91bb833b0d0..2eb43a582e2 100644 --- a/lib/app.php +++ b/lib/app.php @@ -223,8 +223,7 @@ class OC_App{ // check if the app is compatible with this version of ownCloud $info=OC_App::getAppInfo($app); $version=OC_Util::getVersion(); - $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); - if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { + if(!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) { OC_Log::write('core', 'App "'.$info['name'].'" can\'t be installed because it is' .' not compatible with this version of ownCloud', @@ -852,8 +851,7 @@ class OC_App{ foreach($apps as $app) { // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); - $fullVersion = (float) ($version[0] . '.' . $version[1] . $version[2]); - if(!isset($info['require']) or ($fullVersion < (float) $info['require'])) { + if(!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) { OC_Log::write('core', 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is' .' not compatible with this version of ownCloud', @@ -864,6 +862,36 @@ class OC_App{ } } + + /** + * Compares the app version with the owncloud version to see if the app + * requires a newer version than the currently active one + * @param array $owncloudVersions array with 3 entries: major minor bugfix + * @param string $appRequired the required version from the xml + * major.minor.bugfix + * @return boolean true if compatible, otherwise false + */ + public static function isAppVersionCompatible($owncloudVersions, $appRequired){ + $appVersions = explode('.', $appRequired); + + for($i=0; $i + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +class Test_App extends PHPUnit_Framework_TestCase { + + + public function testIsAppVersionCompatibleSingleOCNumber(){ + $oc = array(4); + $app = '4.0'; + + $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app)); + } + + + public function testIsAppVersionCompatibleMultipleOCNumber(){ + $oc = array(4, 3, 1); + $app = '4.3'; + + $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app)); + } + + + public function testIsAppVersionCompatibleMultipleAppNumber(){ + $oc = array(4); + $app = '4'; + + $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app)); + } + + + public function testIsAppVersionCompatibleSingleAppNumber(){ + $oc = array(4, 3); + $app = '4'; + + $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app)); + } + + + public function testIsAppVersionCompatibleShouldFail(){ + $oc = array(4, 3, 1); + $app = '4.3.2'; + + $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app)); + } + + +} \ No newline at end of file From 8068051ca42395db7386db3f8993276ad1b1007b Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 25 Feb 2013 12:47:34 +0100 Subject: [PATCH 17/19] more tests to fail the version check --- tests/lib/app.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/lib/app.php b/tests/lib/app.php index 2bcc34d3321..9cab36903a2 100644 --- a/tests/lib/app.php +++ b/tests/lib/app.php @@ -25,7 +25,7 @@ class Test_App extends PHPUnit_Framework_TestCase { } - public function testIsAppVersionCompatibleMultipleAppNumber(){ + public function testIsAppVersionCompatibleSingleNumber(){ $oc = array(4); $app = '4'; @@ -48,5 +48,19 @@ class Test_App extends PHPUnit_Framework_TestCase { $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app)); } + public function testIsAppVersionCompatibleShouldFailTwoVersionNumbers(){ + $oc = array(4, 3, 1); + $app = '4.4'; + + $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app)); + } + + + public function testIsAppVersionCompatibleShouldFailOneVersionNumbers(){ + $oc = array(4, 3, 1); + $app = '5'; + + $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app)); + } } \ No newline at end of file From 7ebbecd81f433bfdd3353d7be26cb462af423eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Mon, 25 Feb 2013 14:09:20 +0100 Subject: [PATCH 18/19] always use "===" --- apps/files_trashbin/lib/trash.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 83fc424834c..d4ab5ee7dbc 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -102,10 +102,10 @@ class Trashbin { // get available disk space for user $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($user, 'files', 'quota')); - if ( $quota == null ) { + if ( $quota === null ) { $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota')); } - if ( $quota == null ) { + if ( $quota === null ) { $quota = \OC\Files\Filesystem::free_space('/'); } @@ -181,7 +181,7 @@ class Trashbin { } else { $versionedFile = $file; } - if ( $result[0]['type'] == 'dir' ) { + if ( $result[0]['type'] === 'dir' ) { $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.'files_trashbin/versions/'. $file)); $view->rename(\OC_Filesystem::normalizePath('files_trashbin/versions/'. $file), \OC_Filesystem::normalizePath('files_versions/'.$location.'/'.$filename.$ext)); } else if ( $versions = self::getVersionsFromTrash($versionedFile, $timestamp) ) { @@ -199,7 +199,7 @@ class Trashbin { // Take care of encryption keys TODO! Get '.key' in file between file name and delete date (also for permanent delete!) $parts = pathinfo($file); - if ( $result[0]['type'] == 'dir' ) { + if ( $result[0]['type'] === 'dir' ) { $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$parts['dirname'].'/'.$filename); } else { $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$parts['dirname'].'/'.$filename.'.key'); @@ -208,7 +208,7 @@ class Trashbin { $keyfile .= '.d'.$timestamp; } if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) { - if ( $result[0]['type'] == 'dir' ) { + if ( $result[0]['type'] === 'dir' ) { $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile)); $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename); } else { From 7da97550df61e7a82463b91139e8f18923765bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Mon, 25 Feb 2013 14:12:56 +0100 Subject: [PATCH 19/19] some final code clean-up --- apps/files_trashbin/lib/trash.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index d4ab5ee7dbc..5963f9a1b7c 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -56,8 +56,9 @@ class Trashbin { } else { $type = 'file'; } - - if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { + + $trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size'); + if ( $trashbinSize === null ) { $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); } $trashbinSize += self::copy_recursive($file_path, 'files_trashbin/files/'.$deleted.'.d'.$timestamp, $view); @@ -133,7 +134,8 @@ class Trashbin { $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user); - if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { + $trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size'); + if ( $trashbinSize === null ) { $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); } if ( $timestamp ) { @@ -242,7 +244,8 @@ class Trashbin { $view = new \OC_FilesystemView('/'.$user); $size = 0; - if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { + $trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size'); + if ( $trashbinSize === null ) { $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); }