aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-03-16 14:28:42 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2013-03-16 14:28:42 -0400
commitc69dc3483a937e121f7102b95c43d969ac2fb7e1 (patch)
treef2350332bb3bdb7cff2b4cf3f380343c5bd59db6
parentdfbf57207d2d47a843b514728b7254e76930b20c (diff)
downloadnextcloud-server-c69dc3483a937e121f7102b95c43d969ac2fb7e1.tar.gz
nextcloud-server-c69dc3483a937e121f7102b95c43d969ac2fb7e1.zip
Add error handling to the file cache upgrade
-rw-r--r--lib/files/cache/upgrade.php40
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php
index 811d82d7437..230690d35c3 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/files/cache/upgrade.php
@@ -39,9 +39,10 @@ class Upgrade {
if ($row = $this->legacy->get($path)) {
$data = $this->getNewData($row);
- $this->insert($data);
-
- $this->upgradeChilds($data['id'], $mode);
+ if ($data) {
+ $this->insert($data);
+ $this->upgradeChilds($data['id'], $mode);
+ }
}
}
@@ -53,9 +54,11 @@ class Upgrade {
foreach ($children as $child) {
$childData = $this->getNewData($child);
\OC_Hook::emit('\OC\Files\Cache\Upgrade', 'migrate_path', $child['path']);
- $this->insert($childData);
- if ($mode == Scanner::SCAN_RECURSIVE) {
- $this->upgradeChilds($child['id']);
+ if ($childData) {
+ $this->insert($childData);
+ if ($mode == Scanner::SCAN_RECURSIVE) {
+ $this->upgradeChilds($child['id']);
+ }
}
}
}
@@ -95,20 +98,25 @@ class Upgrade {
*/
function getNewData($data) {
$newData = $data;
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']);
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath;
*/
- $newData['path_hash'] = md5($internalPath);
- $newData['path'] = $internalPath;
- $newData['storage'] = $this->getNumericId($storage);
- $newData['parent'] = ($internalPath === '') ? -1 : $data['parent'];
- $newData['permissions'] = ($data['writable']) ? \OCP\PERMISSION_ALL : \OCP\PERMISSION_READ;
- $newData['storage_object'] = $storage;
- $newData['mimetype'] = $this->getMimetypeId($newData['mimetype'], $storage);
- $newData['mimepart'] = $this->getMimetypeId($newData['mimepart'], $storage);
- return $newData;
+ list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']);
+ if ($storage) {
+ $newData['path_hash'] = md5($internalPath);
+ $newData['path'] = $internalPath;
+ $newData['storage'] = $this->getNumericId($storage);
+ $newData['parent'] = ($internalPath === '') ? -1 : $data['parent'];
+ $newData['permissions'] = ($data['writable']) ? \OCP\PERMISSION_ALL : \OCP\PERMISSION_READ;
+ $newData['storage_object'] = $storage;
+ $newData['mimetype'] = $this->getMimetypeId($newData['mimetype'], $storage);
+ $newData['mimepart'] = $this->getMimetypeId($newData['mimepart'], $storage);
+ return $newData;
+ } else {
+ \OC_Log::write('core', 'Unable to migrate data from old cache for '.$data['path'].' because the storage was not found', \OC_Log::ERROR);
+ return false;
+ }
}
/**