Merge pull request #2383 from owncloud/error-handling-upgrade
Add error handling to the file cache upgrade
This commit is contained in:
commit
a3db54f9b0
|
@ -39,11 +39,12 @@ class Upgrade {
|
||||||
|
|
||||||
if ($row = $this->legacy->get($path)) {
|
if ($row = $this->legacy->get($path)) {
|
||||||
$data = $this->getNewData($row);
|
$data = $this->getNewData($row);
|
||||||
|
if ($data) {
|
||||||
$this->insert($data);
|
$this->insert($data);
|
||||||
|
|
||||||
$this->upgradeChilds($data['id'], $mode);
|
$this->upgradeChilds($data['id'], $mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
@ -53,12 +54,14 @@ class Upgrade {
|
||||||
foreach ($children as $child) {
|
foreach ($children as $child) {
|
||||||
$childData = $this->getNewData($child);
|
$childData = $this->getNewData($child);
|
||||||
\OC_Hook::emit('\OC\Files\Cache\Upgrade', 'migrate_path', $child['path']);
|
\OC_Hook::emit('\OC\Files\Cache\Upgrade', 'migrate_path', $child['path']);
|
||||||
|
if ($childData) {
|
||||||
$this->insert($childData);
|
$this->insert($childData);
|
||||||
if ($mode == Scanner::SCAN_RECURSIVE) {
|
if ($mode == Scanner::SCAN_RECURSIVE) {
|
||||||
$this->upgradeChilds($child['id']);
|
$this->upgradeChilds($child['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data the data for the new cache
|
* @param array $data the data for the new cache
|
||||||
|
@ -95,11 +98,12 @@ class Upgrade {
|
||||||
*/
|
*/
|
||||||
function getNewData($data) {
|
function getNewData($data) {
|
||||||
$newData = $data;
|
$newData = $data;
|
||||||
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']);
|
|
||||||
/**
|
/**
|
||||||
* @var \OC\Files\Storage\Storage $storage
|
* @var \OC\Files\Storage\Storage $storage
|
||||||
* @var string $internalPath;
|
* @var string $internalPath;
|
||||||
*/
|
*/
|
||||||
|
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']);
|
||||||
|
if ($storage) {
|
||||||
$newData['path_hash'] = md5($internalPath);
|
$newData['path_hash'] = md5($internalPath);
|
||||||
$newData['path'] = $internalPath;
|
$newData['path'] = $internalPath;
|
||||||
$newData['storage'] = $this->getNumericId($storage);
|
$newData['storage'] = $this->getNumericId($storage);
|
||||||
|
@ -109,6 +113,10 @@ class Upgrade {
|
||||||
$newData['mimetype'] = $this->getMimetypeId($newData['mimetype'], $storage);
|
$newData['mimetype'] = $this->getMimetypeId($newData['mimetype'], $storage);
|
||||||
$newData['mimepart'] = $this->getMimetypeId($newData['mimepart'], $storage);
|
$newData['mimepart'] = $this->getMimetypeId($newData['mimepart'], $storage);
|
||||||
return $newData;
|
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