]> source.dussan.org Git - nextcloud-server.git/commitdiff
update file paths in filecache when the parent is renamed
authorRobin Appelman <icewind@owncloud.com>
Mon, 4 Jun 2012 15:59:21 +0000 (17:59 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 4 Jun 2012 15:59:42 +0000 (17:59 +0200)
lib/filecache.php

index a29e29928a84d19743d659141aa542af020ae15d..3fb8e4113cba2d85660fe5ddb0d74852fedc4f41 100644 (file)
@@ -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)));
+               }
        }
 
        /**