]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make FileCache upgrade more robust, fixes #2650
authorArthur Schiwon <blizzz@owncloud.com>
Fri, 5 Apr 2013 09:27:08 +0000 (11:27 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Fri, 5 Apr 2013 09:27:08 +0000 (11:27 +0200)
lib/files/cache/legacy.php
lib/files/cache/upgrade.php

index 7604d5eb85a9cee4274cf53da15703d0e9ccd6ea..f6e53ab65b49b96087dd05b8305a6b192f67c64d 100644 (file)
@@ -73,7 +73,7 @@ class Legacy {
                }
                $result = $query->execute(array($path));
                $data = $result->fetchRow();
-               $data['etag'] = $this->getEtag($data['path']);
+               $data['etag'] = $this->getEtag($data['path'], $data['user']);
                return $data;
        }
 
@@ -83,12 +83,24 @@ class Legacy {
         * @param type $path
         * @return string
         */
-       function getEtag($path) {
+       function getEtag($path, $user = null) {
                static $query = null;
-               list(, $user, , $relativePath) = explode('/', $path, 4);
-               if (is_null($relativePath)) {
+
+               $pathDetails = explode('/', $path, 4);
+               if((!$user) && !isset($pathDetails[1])) {
+                       //no user!? Too odd, return empty string.
+                       return '';
+               } else if(!$user) {
+                       //guess user from path, if no user passed.
+                       $user = $pathDetails[1];
+               }
+
+               if(!isset($pathDetails[3]) || is_null($pathDetails[3])) {
                        $relativePath = '';
+               } else {
+                       $relativePath = $pathDetails[3];
                }
+
                if(is_null($query)){
                        $query = \OC_DB::prepare('SELECT `propertyvalue` FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = \'{DAV:}getetag\'');
                }
@@ -109,7 +121,7 @@ class Legacy {
                $result = $query->execute(array($id));
                $data = $result->fetchAll();
                foreach ($data as $i => $item) {
-                       $data[$i]['etag'] = $this->getEtag($item['path']);
+                       $data[$i]['etag'] = $this->getEtag($item['path'], $item['user']);
                }
                return $data;
        }
index 0d5bed5c8175d8bd10ae21c2307b36eb0327036e..f8fc96ad1701e570dd08c3217a773f919a8c141e 100644 (file)
@@ -120,6 +120,10 @@ class Upgrade {
         * @return array
         */
        function getNewData($data) {
+               //Make sure there is a path, otherwise we can do nothing.
+               if(!isset($data['path'])) {
+                       return false;
+               }
                $newData = $data;
                /**
                 * @var \OC\Files\Storage\Storage $storage