summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-04-05 11:27:08 +0200
committerArthur Schiwon <blizzz@owncloud.com>2013-04-15 11:56:30 +0200
commit2fa34d6772ae578911dca17bbb0dc7a755024d05 (patch)
tree12f727494b839fe56faccdc7434695692530c1d1
parente13e4c412f1f579a3e6943c71bfd203ecfe4b203 (diff)
downloadnextcloud-server-2fa34d6772ae578911dca17bbb0dc7a755024d05.tar.gz
nextcloud-server-2fa34d6772ae578911dca17bbb0dc7a755024d05.zip
Make FileCache upgrade more robust, fixes #2650
-rw-r--r--lib/files/cache/legacy.php22
-rw-r--r--lib/files/cache/upgrade.php4
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/files/cache/legacy.php b/lib/files/cache/legacy.php
index 9556a2639a3..b8e2548639b 100644
--- a/lib/files/cache/legacy.php
+++ b/lib/files/cache/legacy.php
@@ -80,7 +80,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;
}
@@ -90,12 +90,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\'');
}
@@ -118,7 +130,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;
}
diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php
index 797f4e6ba8c..ca044ba81de 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/files/cache/upgrade.php
@@ -127,6 +127,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