Merge pull request #2383 from owncloud/error-handling-upgrade

Add error handling to the file cache upgrade
This commit is contained in:
Bernhard Posselt 2013-03-16 12:17:31 -07:00
commit a3db54f9b0
1 changed files with 24 additions and 16 deletions

View File

@ -39,11 +39,12 @@ class Upgrade {
if ($row = $this->legacy->get($path)) {
$data = $this->getNewData($row);
if ($data) {
$this->insert($data);
$this->upgradeChilds($data['id'], $mode);
}
}
}
/**
* @param int $id
@ -53,12 +54,14 @@ class Upgrade {
foreach ($children as $child) {
$childData = $this->getNewData($child);
\OC_Hook::emit('\OC\Files\Cache\Upgrade', 'migrate_path', $child['path']);
if ($childData) {
$this->insert($childData);
if ($mode == Scanner::SCAN_RECURSIVE) {
$this->upgradeChilds($child['id']);
}
}
}
}
/**
* @param array $data the data for the new cache
@ -95,11 +98,12 @@ 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;
*/
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']);
if ($storage) {
$newData['path_hash'] = md5($internalPath);
$newData['path'] = $internalPath;
$newData['storage'] = $this->getNumericId($storage);
@ -109,6 +113,10 @@ class Upgrade {
$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;
}
}
/**