diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-12-14 14:16:06 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-11 11:40:58 +0100 |
commit | 282f67dad126da438bfe8a0a89ad0aba21651c75 (patch) | |
tree | 5a49cb930b1aa819beb5ccb0d050fe4901d1d24b /apps/files_versions | |
parent | 8890c88c119f9b1faaa6e60b3230561d8942973e (diff) | |
download | nextcloud-server-282f67dad126da438bfe8a0a89ad0aba21651c75.tar.gz nextcloud-server-282f67dad126da438bfe8a0a89ad0aba21651c75.zip |
improve handling of non existing files in the trashbin
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/storage.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php index e1312841653..82b0d896fac 100644 --- a/apps/files_versions/lib/storage.php +++ b/apps/files_versions/lib/storage.php @@ -42,6 +42,8 @@ namespace OCA\Files_Versions; use OC\Files\Filesystem; +use OC\Search\Provider\File; +use OCA\Activity\Extension\Files; use OCA\Files_Versions\AppInfo\Application; use OCA\Files_Versions\Command\Expire; use OCP\Lock\ILockingProvider; @@ -135,7 +137,12 @@ class Storage { // to get the right target $ext = pathinfo($filename, PATHINFO_EXTENSION); if ($ext === 'part') { - $filename = substr($filename, 0, strlen($filename)-5); + $filename = substr($filename, 0, strlen($filename) - 5); + } + + // we only handle existing files + if (! Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) { + return false; } list($uid, $filename) = self::getUidAndFilename($filename); @@ -143,15 +150,8 @@ class Storage { $files_view = new \OC\Files\View('/'.$uid .'/files'); $users_view = new \OC\Files\View('/'.$uid); - // check if filename is a directory - if($files_view->is_dir($filename)) { - return false; - } - - // we should have a source file to work with, and the file shouldn't - // be empty - $fileExists = $files_view->file_exists($filename); - if (!($fileExists && $files_view->filesize($filename) > 0)) { + // no use making versions for empty files + if ($files_view->filesize($filename) === 0) { return false; } @@ -638,6 +638,11 @@ class Storage { $expiration = self::getExpiration(); if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) { + + if (!Filesystem::file_exists($filename)) { + return false; + } + list($uid, $filename) = self::getUidAndFilename($filename); if (empty($filename)) { // file maybe renamed or deleted |