Skip to content

Commit

Permalink
Use transactions when renaming directory contents
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Feb 6, 2015
1 parent 80e38b8 commit 6c00521
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/private/files/cache/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,14 @@ public function move($source, $target) {
$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` = ?';
Expand Down

0 comments on commit 6c00521

Please sign in to comment.