Skip to content

Commit

Permalink
Merge pull request #31992 from owncloud/stable10-empty-path-has-no-pa…
Browse files Browse the repository at this point in the history
…rents

[stable10] empty path has no parents
  • Loading branch information
DeepDiver1975 authored Jul 18, 2018
2 parents 404624c + 42a71c9 commit 927d907
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/private/Files/Cache/Propagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public function propagateChange($internalPath, $time, $sizeDifference = 0) {

$parents = $this->getParents($internalPath);

if (\count($parents) === 0) {
return;
}

if ($this->inBatch) {
foreach ($parents as $parent) {
$this->addToBatch($parent, $time, $sizeDifference);
Expand Down Expand Up @@ -100,6 +104,9 @@ public function propagateChange($internalPath, $time, $sizeDifference = 0) {
}

protected function getParents($path) {
if ($path === '') {
return [];
}
$parts = explode('/', $path);
$parent = '';
$parents = [];
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/Files/Cache/PropagatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ public function testSizePropagation() {
}
}

public function getParentsProvider() {
return [
['', []],
['foo', ['']],
['foo/bar', ['', 'foo']],
['foo/bar/baz.txt', ['', 'foo', 'foo/bar']]
];
}

/**
* @dataProvider getParentsProvider
* @param $path
* @throws \OCP\Files\StorageNotAvailableException
*/
public function testGetParents($path, $expected) {
$propagator = $this->storage->getPropagator();
self::assertSame($expected, self::invokePrivate($propagator, 'getParents', [$path]));
}

public function testBatchedPropagation() {
$this->storage->mkdir('foo/baz');
$this->storage->mkdir('asd');
Expand Down

0 comments on commit 927d907

Please sign in to comment.