aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-16 12:17:31 -0700
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-16 12:17:31 -0700
commita3db54f9b04ef16bc0bf6a3a6934a72e25a55214 (patch)
tree5e6a0d41abd292dd236a895eb020ae0c104cd302
parent25175937a9a810ad0aadab473f936d27e914abab (diff)
parentc69dc3483a937e121f7102b95c43d969ac2fb7e1 (diff)
downloadnextcloud-server-a3db54f9b04ef16bc0bf6a3a6934a72e25a55214.tar.gz
nextcloud-server-a3db54f9b04ef16bc0bf6a3a6934a72e25a55214.zip
Merge pull request #2383 from owncloud/error-handling-upgrade
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;
+ }
}
/**