]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove no longer existing files from the cache when scanning external storage
authorRobin Appelman <icewind@owncloud.com>
Thu, 14 Aug 2014 12:50:52 +0000 (14:50 +0200)
committerRobin Appelman <icewind@owncloud.com>
Thu, 14 Aug 2014 12:50:52 +0000 (14:50 +0200)
apps/files_sharing/lib/external/scanner.php

index 4dc5d4be9d866c24defa6a6b9a067fd3284462f3..4e61e0c4ccb0638fc57b0097e1587829982804b2 100644 (file)
@@ -28,11 +28,21 @@ class Scanner extends \OC\Files\Cache\Scanner {
        }
 
        private function addResult($data, $path) {
-               $this->cache->put($path, $data);
+               $id = $this->cache->put($path, $data);
                if (isset($data['children'])) {
+                       $children = array();
                        foreach ($data['children'] as $child) {
+                               $children[$child['name']] = true;
                                $this->addResult($child, ltrim($path . '/' . $child['name'], '/'));
                        }
+
+                       $existingCache = $this->cache->getFolderContentsById($id);
+                       foreach ($existingCache as $existingChild) {
+                               // if an existing child is not in the new data, remove it
+                               if (!isset($children[$existingChild['name']])) {
+                                       $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/'));
+                               }
+                       }
                }
        }
 }