Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File cache hole check only report storage id once #33468

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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