aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-06-20 00:42:34 +0200
committerRobin Appelman <icewind@owncloud.com>2013-06-20 00:42:34 +0200
commitff7e903f82607fdbc73e17dd7bb6bcc2caeb3de7 (patch)
tree0e30d10b21397bb01ad3f65cd15a13f2cbba5e16 /lib/files
parente3171a701d2c88a12ec11cebb5d96ff2fb6cf677 (diff)
downloadnextcloud-server-ff7e903f82607fdbc73e17dd7bb6bcc2caeb3de7.tar.gz
nextcloud-server-ff7e903f82607fdbc73e17dd7bb6bcc2caeb3de7.zip
remove deleted files when re-scanning a folder
Diffstat (limited to 'lib/files')
-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);