Skip to content

Commit

Permalink
Fix StorageFolder::sync() for NC >= 18
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Rudolf <[email protected]>
  • Loading branch information
PhrozenByte committed Dec 15, 2019
1 parent 2f52a44 commit 9fa5805
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/Files/StorageFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use OC\Files\Utils\Scanner;
use OC\ForbiddenException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder as OCFolder;
use OCP\Files\InvalidPathException;
use OCP\Files\NotPermittedException;
Expand All @@ -52,6 +53,9 @@ class StorageFolder extends AbstractStorageNode implements FolderInterface
/** @var ILogger */
private $logger;

/** @var IEventDispatcher|null */
private $eventDispatcher;

/**
* StorageFolder constructor.
*
Expand Down Expand Up @@ -156,7 +160,17 @@ public function fakeRoot(): FolderInterface
*/
public function sync(bool $recursive = FolderInterface::SYNC_RECURSIVE)
{
$scanner = new Scanner(null, $this->connection, $this->logger);
// TODO >= NC 18: Remove version switch
list($majorVersion) = \OC_Util::getVersion();
if ($majorVersion >= 18) {
if ($this->eventDispatcher === null) {
$this->eventDispatcher = \OC::$server->query(IEventDispatcher::class);
}

$scanner = new Scanner(null, $this->connection, $this->eventDispatcher, $this->logger);
} else {
$scanner = new Scanner(null, $this->connection, $this->logger);
}

try {
$scanner->scan($this->node->getPath(), $recursive);
Expand Down

0 comments on commit 9fa5805

Please sign in to comment.