summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Tomlinson <fallen013@gmail.com>2014-08-25 11:28:50 -0400
committerClark Tomlinson <fallen013@gmail.com>2014-08-25 11:28:50 -0400
commit58ab10551546c8035de69bc55ffabdc1e5627b4f (patch)
treefe6e1d4773218444a33f496eb6f374717b0709ee
parentc86824fa09b116e8d24ac5c3b0b72f5c4455f290 (diff)
parentbbe17f35a17af28410915e9dcb1263cc51edcb49 (diff)
downloadnextcloud-server-58ab10551546c8035de69bc55ffabdc1e5627b4f.tar.gz
nextcloud-server-58ab10551546c8035de69bc55ffabdc1e5627b4f.zip
Merge pull request #10421 from owncloud/share-external-delete
Remove no longer existing files from the cache when scanning external storage
-rw-r--r--apps/files_sharing/lib/external/scanner.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/external/scanner.php b/apps/files_sharing/lib/external/scanner.php
index 4dc5d4be9d8..4e61e0c4ccb 100644
--- a/apps/files_sharing/lib/external/scanner.php
+++ b/apps/files_sharing/lib/external/scanner.php
@@ -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'], '/'));
+ }
+ }
}
}
}