mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Remove no longer existing files from the cache when scanning external storage
This commit is contained in:
parent
a4b416f115
commit
bbe17f35a1
1 changed files with 11 additions and 1 deletions
12
apps/files_sharing/lib/external/scanner.php
vendored
12
apps/files_sharing/lib/external/scanner.php
vendored
|
|
@ -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'], '/'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue