From: Robin Appelman Date: Mon, 4 Jun 2012 15:59:21 +0000 (+0200) Subject: update file paths in filecache when the parent is renamed X-Git-Tag: v4.5.0beta1~74^2~424^2~32^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=59086fe08224d772af3a13d8c2f83990acd77ce6;p=nextcloud-server.git update file paths in filecache when the parent is renamed --- diff --git a/lib/filecache.php b/lib/filecache.php index a29e29928a8..3fb8e4113cb 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -169,6 +169,15 @@ class OC_FileCache{ $newParent=self::getParentId($newPath); $query=OC_DB::prepare('UPDATE *PREFIX*fscache SET parent=? ,name=?, path=?, path_hash=? WHERE path_hash=?'); $query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath))); + + $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE path LIKE ?'); + $oldLength=strlen($oldPath); + $updateQuery=OC_DB::prepare('UPDATE *PREFIX*fscache SET path=?, path_hash=? WHERE path_hash=?'); + while($row= $query->execute(array($oldPath.'/%'))->fetchRow()){ + $old=$row['path']; + $new=$newPath.substr($old,$oldLength); + $updateQuery->execute(array($new,md5($new),md5($old))); + } } /**