Merge pull request #13948 from owncloud/cache-move-transaction

Use transactions when renaming directory contents
This commit is contained in:
Lukas Reschke 2015-02-08 19:08:52 +01:00
commit 0e604aa875
1 changed files with 2 additions and 0 deletions

View File

@ -408,12 +408,14 @@ class Cache {
$result = \OC_DB::executeAudited($sql, array($this->getNumericStorageId(), $source . '/%'));
$childEntries = $result->fetchAll();
$sourceLength = strlen($source);
\OC_DB::beginTransaction();
$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ? WHERE `fileid` = ?');
foreach ($childEntries as $child) {
$targetPath = $target . substr($child['path'], $sourceLength);
\OC_DB::executeAudited($query, array($targetPath, md5($targetPath), $child['fileid']));
}
\OC_DB::commit();
}
$sql = 'UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `name` = ?, `parent` =? WHERE `fileid` = ?';