]> source.dussan.org Git - nextcloud-server.git/commitdiff
improve handling of non existing files in the trashbin
authorRobin Appelman <icewind@owncloud.com>
Mon, 14 Dec 2015 13:16:06 +0000 (14:16 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 11 Jan 2016 10:40:58 +0000 (11:40 +0100)
apps/files_versions/lib/storage.php

index e131284165337c66f4f5420e487af5a877e42c8b..82b0d896facad69f9283ecd7e5c79fe04e2df74f 100644 (file)
@@ -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