Skip to content

Commit

Permalink
Merge pull request #33468 from owncloud/fix-repair-filecache-check-ou…
Browse files Browse the repository at this point in the history
…tput

File cache hole check only report storage id once
  • Loading branch information
Vincent Petry authored Nov 15, 2018
2 parents 31f9ad4 + a7e3715 commit 81d5e68
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/private/Repair/RepairMismatchFileCachePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ private function reportAffectedStoragesParentIdWrongPath(IOutput $out) {

$storageIds = [];
foreach ($rows as $row) {
$storageIds[] = $row['storage'];
$storageIds[$row['storage']] = true;
}

$storageIds = \array_keys($storageIds);
if (!empty($storageIds)) {
$out->warning('The file cache contains entries with invalid path values for the following storage numeric ids: ' . \implode(' ', $storageIds));
$out->warning('Please run `occ files:scan --all --repair` to repair'
Expand All @@ -271,9 +272,10 @@ private function reportAffectedStoragesNonExistingParentIdEntry(IOutput $out) {

$storageIds = [];
foreach ($rows as $row) {
$storageIds[] = $row['storage'];
$storageIds[$row['storage']] = true;
}

$storageIds = \array_keys($storageIds);
if (!empty($storageIds)) {
$out->warning('The file cache contains entries where the parent id does not point to any existing entry for the following storage numeric ids: ' . \implode(' ', $storageIds));
$out->warning('Please run `occ files:scan --all --repair` to repair all affected storages');
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/Repair/RepairMismatchFileCachePathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ public function testRepairEntry($sourceStorageId, $targetStorageId, $targetDir,
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn('10.0.3');

// test report command first
$this->repair->setCountOnly(true);
$outputMock->expects($this->at(0))
->method('warning')
->with($this->logicalAnd($this->stringContains('with invalid path values'), $this->stringContains($sourceStorageId)));
$this->repair->run($outputMock);
$this->repair->setCountOnly(false);

if ($repairStoragesOrder === null) {
// no storage selected, full repair
$this->repair->setStorageNumericId(null);
Expand Down Expand Up @@ -552,6 +561,13 @@ public function testRepairParentIdPointingNowhere() {
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn('10.0.3');

$this->repair->setCountOnly(true);
$outputMock->expects($this->at(0))
->method('warning')
->with($this->logicalAnd($this->stringContains('parent id does not point'), $this->stringContains($storageId)));
$this->repair->run($outputMock);
$this->repair->setCountOnly(false);
$this->repair->run($outputMock);

// wrong parent root reparented to actual root
Expand Down

0 comments on commit 81d5e68

Please sign in to comment.