Skip to content
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
21 changes: 16 additions & 5 deletions lib/private/files/utils/scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,20 @@ protected function attachListener($mount) {
public function backgroundScan($dir) {
$mounts = $this->getMounts($dir);
foreach ($mounts as $mount) {
if (is_null($mount->getStorage())) {
$storage = $mount->getStorage();
if (is_null($storage)) {
continue;
}
// don't scan the root storage
if ($mount->getStorage()->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') {
if ($storage->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') {
continue;
}
$scanner = $mount->getStorage()->getScanner();

// don't scan received local shares, these can be scanned when scanning the owner's storage
if ($storage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
continue;
}
$scanner = $storage->getScanner();
$this->attachListener($mount);
$scanner->backgroundScan();
}
Expand All @@ -140,10 +146,10 @@ public function scan($dir = '') {
}
$mounts = $this->getMounts($dir);
foreach ($mounts as $mount) {
if (is_null($mount->getStorage())) {
$storage = $mount->getStorage();
if (is_null($storage)) {
continue;
}
$storage = $mount->getStorage();
// if the home storage isn't writable then the scanner is run as the wrong user
if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and
(!$storage->isCreatable('') or !$storage->isCreatable('files'))
Expand All @@ -155,6 +161,11 @@ public function scan($dir = '') {
}

}

// don't scan received local shares, these can be scanned when scanning the owner's storage
if ($storage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
continue;
}
$relativePath = $mount->getInternalPath($dir);
$scanner = $storage->getScanner();
$scanner->setUseTransactions(false);
Expand Down
22 changes: 22 additions & 0 deletions tests/lib/files/utils/scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,26 @@ public function testPropagateEtag() {

$this->assertNotEquals($oldRoot->getEtag(), $newRoot->getEtag());
}

public function testSkipLocalShares() {
$sharedStorage = $this->getMockBuilder('OC\Files\Storage\Shared')
->disableOriginalConstructor()
->getMock();
$sharedMount = new MountPoint($sharedStorage, '/share');
Filesystem::getMountManager()->addMount($sharedMount);

$sharedStorage->expects($this->any())
->method('instanceOfStorage')
->will($this->returnValueMap([
['OCA\Files_Sharing\ISharedStorage', true],
]));
$sharedStorage->expects($this->never())
->method('getScanner');

$scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger());
$scanner->addMount($sharedMount);
$scanner->scan('');

$scanner->backgroundScan('');
}
}