]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cache: also check if the file id is already in the cache during upgrade
authorRobin Appelman <icewind@owncloud.com>
Mon, 4 Mar 2013 21:26:03 +0000 (22:26 +0100)
committerRobin Appelman <icewind@owncloud.com>
Mon, 4 Mar 2013 21:26:03 +0000 (22:26 +0100)
Should solve upgrade issues if only some of the configured storages were migrated previously

lib/files/cache/upgrade.php

index 1fe4c5846867b20b5f1bb15803a0000038a6b0eb..4d98abb2f8d92a59b7f075479fb09f5edf13e70e 100644 (file)
@@ -64,7 +64,7 @@ class Upgrade {
         * @param array $data the data for the new cache
         */
        function insert($data) {
-               if (!$this->inCache($data['storage'], $data['path_hash'])) {
+               if (!$this->inCache($data['storage'], $data['path_hash'], $data['id'])) {
                        $insertQuery = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`
                                        ( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` )
                                        VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
@@ -78,12 +78,19 @@ class Upgrade {
        /**
         * @param string $storage
         * @param string $pathHash
+        * @param string $id
         * @return bool
         */
-       function inCache($storage, $pathHash) {
+       function inCache($storage, $pathHash, $id) {
                $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
                $result = $query->execute(array($storage, $pathHash));
-               return (bool)$result->fetchRow();
+               if ($result->fetchRow()) {
+                       return true;
+               } else {
+                       $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
+                       $result = $query->execute(array($id));
+                       return (bool)$result->fetchRow();
+               }
        }
 
        /**