summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-06-20 04:02:10 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-06-20 04:02:10 -0700
commit4232ccbc6d96291093e6535f3422920377ba486d (patch)
tree025fed2907ff88c0ceb106a0562cb02a53d5077b /lib
parentc41f11a821991e5bb7153b7009472b404a7866a3 (diff)
parent5d0a3f981c1be8f9a0fd42f3172acf89259739a2 (diff)
downloadnextcloud-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.php14
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);