Skip to content
Snippets Groups Projects
Commit c69dc348 authored by Michael Gapczynski's avatar Michael Gapczynski
Browse files

Add error handling to the file cache upgrade

parent dfbf5720
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment