]> source.dussan.org Git - nextcloud-server.git/commitdiff
Adjust logic for deciding if trashbin empty
authorRobin McCorkell <rmccorkell@karoshi.org.uk>
Sun, 13 Apr 2014 12:47:08 +0000 (13:47 +0100)
committerRobin McCorkell <rmccorkell@karoshi.org.uk>
Sun, 13 Apr 2014 12:49:04 +0000 (13:49 +0100)
Any error in opening the trashbin directory returns 'true' for isEmpty.
An error is prevented by checking if the directory exists before trying to
open it.

apps/files_trashbin/lib/trashbin.php

index 7b14a4ec0816ddae30f00be3bdb4c5c0101c8239..bf8d465e5de977726e5ee87059c2b2d87b813151 100644 (file)
@@ -921,13 +921,11 @@ class Trashbin {
        public static function isEmpty($user) {
 
                $view = new \OC\Files\View('/' . $user . '/files_trashbin');
-               $dh = $view->opendir('/files');
-               if (!$dh) {
-                       return false;
-               }
-               while ($file = readdir($dh)) {
-                       if ($file !== '.' and $file !== '..') {
-                               return false;
+               if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
+                       while ($file = readdir($dh)) {
+                               if ($file !== '.' and $file !== '..') {
+                                       return false;
+                               }
                        }
                }
                return true;