summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-10-04 15:08:49 +0200
committerGitHub <noreply@github.com>2017-10-04 15:08:49 +0200
commit73554a3228d1354aceac3ad90d344144a3fb1bd9 (patch)
tree56cc0833d3dbd96da3fe6ff4adf3ff43c33e6cbf
parente95e7dca277d9d2112149b84c6547acb1a37b5fd (diff)
parent7525c387ce2fd14cb007b434e93c415902d399db (diff)
downloadnextcloud-server-73554a3228d1354aceac3ad90d344144a3fb1bd9.tar.gz
nextcloud-server-73554a3228d1354aceac3ad90d344144a3fb1bd9.zip
Merge pull request #6742 from nextcloud/invalid-path-repair-from11
dont run invalid path repair step when upgrading from 11.0.5.2 and later
-rw-r--r--lib/private/Repair/NC13/RepairInvalidPaths.php14
-rw-r--r--tests/lib/Repair/RepairInvalidPathsTest.php30
2 files changed, 41 insertions, 3 deletions
diff --git a/lib/private/Repair/NC13/RepairInvalidPaths.php b/lib/private/Repair/NC13/RepairInvalidPaths.php
index 8e6a4ca0e37..a8ccb9a579f 100644
--- a/lib/private/Repair/NC13/RepairInvalidPaths.php
+++ b/lib/private/Repair/NC13/RepairInvalidPaths.php
@@ -172,10 +172,18 @@ class RepairInvalidPaths implements IRepairStep {
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');
diff --git a/tests/lib/Repair/RepairInvalidPathsTest.php b/tests/lib/Repair/RepairInvalidPathsTest.php
index b0370f5ae2d..17c584fd149 100644
--- a/tests/lib/Repair/RepairInvalidPathsTest.php
+++ b/tests/lib/Repair/RepairInvalidPathsTest.php
@@ -186,4 +186,34 @@ class RepairInvalidPathsTest extends TestCase {
$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'));
+ }
}