Cache: only look for child entires when doing a move operation when moving a folder
This commit is contained in:
parent
c50dfd7251
commit
10be42f5b7
|
@ -205,7 +205,7 @@ class Cache {
|
||||||
. ' VALUES(' . implode(', ', $valuesPlaceholder) . ')');
|
. ' VALUES(' . implode(', ', $valuesPlaceholder) . ')');
|
||||||
$result = $query->execute($params);
|
$result = $query->execute($params);
|
||||||
if (\OC_DB::isError($result)) {
|
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');
|
return (int)\OC_DB::insertid('*PREFIX*filecache');
|
||||||
|
@ -328,9 +328,11 @@ class Cache {
|
||||||
* @param string $target
|
* @param string $target
|
||||||
*/
|
*/
|
||||||
public function move($source, $target) {
|
public function move($source, $target) {
|
||||||
$sourceId = $this->getId($source);
|
$sourceData = $this->get($source);
|
||||||
|
$sourceId = $sourceData['fileid'];
|
||||||
$newParentId = $this->getParentId($target);
|
$newParentId = $this->getParentId($target);
|
||||||
|
|
||||||
|
if ($sourceData['mimetype'] === 'httpd/unix-directory') {
|
||||||
//find all child entries
|
//find all child entries
|
||||||
$query = \OC_DB::prepare('SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `path` LIKE ?');
|
$query = \OC_DB::prepare('SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `path` LIKE ?');
|
||||||
$result = $query->execute(array($source . '/%'));
|
$result = $query->execute(array($source . '/%'));
|
||||||
|
@ -342,6 +344,7 @@ class Cache {
|
||||||
$targetPath = $target . substr($child['path'], $sourceLength);
|
$targetPath = $target . substr($child['path'], $sourceLength);
|
||||||
$query->execute(array($targetPath, md5($targetPath), $child['fileid']));
|
$query->execute(array($targetPath, md5($targetPath), $child['fileid']));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `name` = ?, `parent` =?'
|
$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `name` = ?, `parent` =?'
|
||||||
. ' WHERE `fileid` = ?');
|
. ' WHERE `fileid` = ?');
|
||||||
|
|
|
@ -162,10 +162,11 @@ class Cache extends \PHPUnit_Framework_TestCase {
|
||||||
$file4 = 'folder/foo/1';
|
$file4 = 'folder/foo/1';
|
||||||
$file5 = 'folder/foo/2';
|
$file5 = 'folder/foo/2';
|
||||||
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
|
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
|
||||||
|
$folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
|
||||||
|
|
||||||
$this->cache->put($file1, $data);
|
$this->cache->put($file1, $folderData);
|
||||||
$this->cache->put($file2, $data);
|
$this->cache->put($file2, $folderData);
|
||||||
$this->cache->put($file3, $data);
|
$this->cache->put($file3, $folderData);
|
||||||
$this->cache->put($file4, $data);
|
$this->cache->put($file4, $data);
|
||||||
$this->cache->put($file5, $data);
|
$this->cache->put($file5, $data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue