summaryrefslogtreecommitdiffstats
path: root/lib/private/Repair
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-07-19 12:30:59 +0200
committerMorris Jobke <hey@morrisjobke.de>2017-07-21 14:06:13 +0200
commit06a4d6b5b9f82954c818de8d26b2a337d0f049e7 (patch)
tree896273dcd315caf1541f75ad50ea261720d17ad1 /lib/private/Repair
parenta33b6cdd21868abf026375503a4eb5a36684c8eb (diff)
downloadnextcloud-server-06a4d6b5b9f82954c818de8d26b2a337d0f049e7.tar.gz
nextcloud-server-06a4d6b5b9f82954c818de8d26b2a337d0f049e7.zip
Also repair storage id's when repairing invalid entries
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Repair')
-rw-r--r--lib/private/Repair/NC13/RepairInvalidPaths.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/Repair/NC13/RepairInvalidPaths.php b/lib/private/Repair/NC13/RepairInvalidPaths.php
index cbbbc82801c..5a4187949a7 100644
--- a/lib/private/Repair/NC13/RepairInvalidPaths.php
+++ b/lib/private/Repair/NC13/RepairInvalidPaths.php
@@ -64,7 +64,7 @@ class RepairInvalidPaths implements IRepairStep {
);
//select f.path, f.parent,p.path from oc_filecache f inner join oc_filecache p on f.parent=p.fileid and p.path!='' where f.path != p.path || '/' || f.name;
- $query = $builder->select('f.fileid', 'f.path', 'p.path AS parent_path', 'f.name', 'f.parent', 'f.storage')
+ $query = $builder->select('f.fileid', 'f.path', 'p.path AS parent_path', 'f.name', 'f.parent', 'f.storage', 'p.storage as parent_storage')
->from('filecache', 'f')
->innerJoin('f', 'filecache', 'p', $builder->expr()->andX(
$builder->expr()->eq('f.parent', 'p.fileid'),
@@ -102,19 +102,22 @@ class RepairInvalidPaths implements IRepairStep {
/**
* @param string $fileid
* @param string $newPath
+ * @param string $newStorage
* @suppress SqlInjectionChecker
*/
- private function update($fileid, $newPath) {
+ private function update($fileid, $newPath, $newStorage) {
if (!$this->updateQuery) {
$builder = $this->connection->getQueryBuilder();
$this->updateQuery = $builder->update('filecache')
->set('path', $builder->createParameter('newpath'))
->set('path_hash', $builder->func()->md5($builder->createParameter('newpath')))
+ ->set('storage', $builder->createParameter('newstorage'))
->where($builder->expr()->eq('fileid', $builder->createParameter('fileid')));
}
$this->updateQuery->setParameter('newpath', $newPath);
+ $this->updateQuery->setParameter('newstorage', $newStorage);
$this->updateQuery->setParameter('fileid', $fileid, IQueryBuilder::PARAM_INT);
$this->updateQuery->execute();
@@ -155,12 +158,12 @@ class RepairInvalidPaths implements IRepairStep {
foreach ($entries as $entry) {
$count++;
$calculatedPath = $entry['parent_path'] . '/' . $entry['name'];
- if ($newId = $this->getId($entry['storage'], $calculatedPath)) {
+ if ($newId = $this->getId($entry['parent_storage'], $calculatedPath)) {
// a new entry with the correct path has already been created, reuse that one and delete the incorrect entry
$this->reparent($entry['fileid'], $newId);
$this->delete($entry['fileid']);
} else {
- $this->update($entry['fileid'], $calculatedPath);
+ $this->update($entry['fileid'], $calculatedPath, $entry['parent_storage']);
}
}
$this->connection->commit();