Add error handling to the file cache upgrade
This commit is contained in:
parent
dfbf57207d
commit
c69dc3483a
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue