diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-04-19 15:03:59 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-04-19 15:06:48 +0200 |
commit | 10be42f5b7b17ca55c242960885a9b50e217af3f (patch) | |
tree | f1fa7359e6419eebe506b27b19e81112cdbbf450 /lib | |
parent | c50dfd725142abdbad93dbcf01fe13193445386a (diff) | |
download | nextcloud-server-10be42f5b7b17ca55c242960885a9b50e217af3f.tar.gz nextcloud-server-10be42f5b7b17ca55c242960885a9b50e217af3f.zip |
Cache: only look for child entires when doing a move operation when moving a folder
Diffstat (limited to 'lib')
-rw-r--r-- | lib/files/cache/cache.php | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 71b70abe3fe..d30c5cd16ed 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -205,7 +205,7 @@ class Cache { . ' VALUES(' . implode(', ', $valuesPlaceholder) . ')'); $result = $query->execute($params); if (\OC_DB::isError($result)) { - \OCP\Util::writeLog('cache', 'Insert to cache failed: '.$result, \OCP\Util::ERROR); + \OCP\Util::writeLog('cache', 'Insert to cache failed: ' . $result, \OCP\Util::ERROR); } return (int)\OC_DB::insertid('*PREFIX*filecache'); @@ -328,19 +328,22 @@ class Cache { * @param string $target */ public function move($source, $target) { - $sourceId = $this->getId($source); + $sourceData = $this->get($source); + $sourceId = $sourceData['fileid']; $newParentId = $this->getParentId($target); - //find all child entries - $query = \OC_DB::prepare('SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `path` LIKE ?'); - $result = $query->execute(array($source . '/%')); - $childEntries = $result->fetchAll(); - $sourceLength = strlen($source); - $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ? WHERE `fileid` = ?'); - - foreach ($childEntries as $child) { - $targetPath = $target . substr($child['path'], $sourceLength); - $query->execute(array($targetPath, md5($targetPath), $child['fileid'])); + if ($sourceData['mimetype'] === 'httpd/unix-directory') { + //find all child entries + $query = \OC_DB::prepare('SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `path` LIKE ?'); + $result = $query->execute(array($source . '/%')); + $childEntries = $result->fetchAll(); + $sourceLength = strlen($source); + $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ? WHERE `fileid` = ?'); + + foreach ($childEntries as $child) { + $targetPath = $target . substr($child['path'], $sourceLength); + $query->execute(array($targetPath, md5($targetPath), $child['fileid'])); + } } $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `name` = ?, `parent` =?' |