]> source.dussan.org Git - nextcloud-server.git/commitdiff
reuse cache move logic
authorRobin Appelman <icewind@owncloud.com>
Wed, 1 Apr 2015 13:15:24 +0000 (15:15 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 13 Apr 2015 15:10:01 +0000 (17:10 +0200)
lib/private/files/cache/cache.php

index fd4c5715a67a3258f5afd8a2f7c50a08edb5edef..ee9da23109001a7a9e9361b8f31a1e350e26c76a 100644 (file)
@@ -435,32 +435,7 @@ class Cache {
         * @param string $target
         */
        public function move($source, $target) {
-               // normalize source and target
-               $source = $this->normalize($source);
-               $target = $this->normalize($target);
-
-               $sourceData = $this->get($source);
-               $sourceId = $sourceData['fileid'];
-               $newParentId = $this->getParentId($target);
-
-               if ($sourceData['mimetype'] === 'httpd/unix-directory') {
-                       //find all child entries
-                       $sql = 'SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path` LIKE ?';
-                       $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` = ?';
-               \OC_DB::executeAudited($sql, array($target, md5($target), basename($target), $newParentId, $sourceId));
+               $this->moveFromCache($this, $source, $target);
        }
 
        /**