Skip to content
Snippets Groups Projects
Commit bbe17f35 authored by Robin Appelman's avatar Robin Appelman
Browse files

Remove no longer existing files from the cache when scanning external storage

parent a4b416f1
No related branches found
No related tags found
No related merge requests found
...@@ -28,11 +28,21 @@ class Scanner extends \OC\Files\Cache\Scanner { ...@@ -28,11 +28,21 @@ class Scanner extends \OC\Files\Cache\Scanner {
} }
private function addResult($data, $path) { private function addResult($data, $path) {
$this->cache->put($path, $data); $id = $this->cache->put($path, $data);
if (isset($data['children'])) { if (isset($data['children'])) {
$children = array();
foreach ($data['children'] as $child) { foreach ($data['children'] as $child) {
$children[$child['name']] = true;
$this->addResult($child, ltrim($path . '/' . $child['name'], '/')); $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'], '/'));
}
}
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment