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

[12] dont run invalid path repair step when upgrading from 11.0.5.2 and later #6743

Merged
merged 1 commit into from Oct 4, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/private/Repair/NC13/RepairInvalidPaths.php
Expand Up @@ -162,10 +162,18 @@ private function repair() {
return $count;
}

public function run(IOutput $output) {
private function shouldRun() {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
// was added to 12.0.0.30 and 13.0.0.1
if (version_compare($versionFromBeforeUpdate, '12.0.0.30', '<') || version_compare($versionFromBeforeUpdate, '13.0.0.0', '==')) {

// was added to 11.0.5.2, 12.0.0.30 and 13.0.0.1
$shouldRun = version_compare($versionFromBeforeUpdate, '11.0.5.2', '<');
$shouldRun |= version_compare($versionFromBeforeUpdate, '12.0.0.0', '>=') && version_compare($versionFromBeforeUpdate, '12.0.0.30', '<');
$shouldRun |= version_compare($versionFromBeforeUpdate, '13.0.0.0', '==');
return $shouldRun;
}

public function run(IOutput $output) {
if ($this->shouldRun()) {
$count = $this->repair();

$output->info('Repaired ' . $count . ' paths');
Expand Down
30 changes: 30 additions & 0 deletions tests/lib/Repair/RepairInvalidPathsTest.php
Expand Up @@ -186,4 +186,34 @@ public function testRepairNonDuplicateBetweenStorage() {
$this->assertEquals($folderId, $this->cache2->get('foo2/bar/asd')['parent']);
$this->assertEquals($folderId, $this->cache2->getId('foo2/bar'));
}

public function shouldRunDataProvider() {
return [
['11.0.0.0', true],
['11.0.0.31', true],
['11.0.5.2', false],
['12.0.0.0', true],
['12.0.0.1', true],
['12.0.0.31', false],
['13.0.0.0', true],
['13.0.0.1', false]
];
}

/**
* @dataProvider shouldRunDataProvider
*
* @param string $from
* @param boolean $expected
*/
public function testShouldRun($from, $expected) {
$config = $this->createMock(IConfig::class);
$config->expects($this->any())
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn($from);
$repair = new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), $config);

$this->assertEquals($expected, $this->invokePrivate($repair, 'shouldRun'));
}
}