diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-06-20 04:02:10 -0700 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-06-20 04:02:10 -0700 |
commit | 4232ccbc6d96291093e6535f3422920377ba486d (patch) | |
tree | 025fed2907ff88c0ceb106a0562cb02a53d5077b /lib | |
parent | c41f11a821991e5bb7153b7009472b404a7866a3 (diff) | |
parent | 5d0a3f981c1be8f9a0fd42f3172acf89259739a2 (diff) | |
download | nextcloud-server-4232ccbc6d96291093e6535f3422920377ba486d.tar.gz nextcloud-server-4232ccbc6d96291093e6535f3422920377ba486d.zip |
Merge pull request #3792 from owncloud/scanfolder-remove
remove deleted files when re-scanning a folder
Diffstat (limited to 'lib')
-rw-r--r-- | lib/files/cache/scanner.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index e7fbd856d5a..9b94a24f481 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -137,11 +137,20 @@ class Scanner { \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_folder', array('path' => $path, 'storage' => $this->storageId)); $size = 0; $childQueue = array(); + $existingChildren = array(); + if ($this->cache->inCache($path)) { + $children = $this->cache->getFolderContents($path); + foreach ($children as $child) { + $existingChildren[] = $child['name']; + } + } + $newChildren = array(); if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) { \OC_DB::beginTransaction(); while ($file = readdir($dh)) { $child = ($path) ? $path . '/' . $file : $file; if (!Filesystem::isIgnoredDir($file)) { + $newChildren[] = $file; $data = $this->scanFile($child, $reuse); if ($data) { if ($data['size'] === -1) { @@ -156,6 +165,11 @@ class Scanner { } } } + $removedChildren = \array_diff($existingChildren, $newChildren); + foreach ($removedChildren as $childName) { + $child = ($path) ? $path . '/' . $childName : $childName; + $this->cache->remove($child); + } \OC_DB::commit(); foreach ($childQueue as $child) { $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE); |