diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-08-14 14:50:52 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-08-14 14:50:52 +0200 |
commit | bbe17f35a17af28410915e9dcb1263cc51edcb49 (patch) | |
tree | 876afe2fb974cfdcaeed6a648d11c3561af1da30 /apps | |
parent | a4b416f115d551b8b1c6a5953ef87bb728697f33 (diff) | |
download | nextcloud-server-bbe17f35a17af28410915e9dcb1263cc51edcb49.tar.gz nextcloud-server-bbe17f35a17af28410915e9dcb1263cc51edcb49.zip |
Remove no longer existing files from the cache when scanning external storage
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/external/scanner.php | 12 |
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'], '/')); + } + } } } } |