Skip to content

Commit

Permalink
Merge pull request #40363 from nextcloud/share-external-watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Feb 24, 2024
2 parents 3343626 + 47350a9 commit ef8cf53
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
use OC\Files\Storage\Home;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\User\NoUserException;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\Files_External\Config\ConfigAdapter;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Folder;
use OCP\Files\IHomeStorage;
use OCP\Files\IRootFolder;
Expand Down Expand Up @@ -431,21 +432,29 @@ public function getOwner($path): string {
}

public function getWatcher($path = '', $storage = null): Watcher {
$mountManager = \OC::$server->getMountManager();
if ($this->watcher) {
return $this->watcher;
}

// Get node information
$node = $this->getShare()->getNodeCacheEntry();
if ($node) {
$mount = $mountManager->findByNumericId($node->getStorageId());
// If the share is originating from an external storage
if (count($mount) > 0 && $mount[0] instanceof ExternalMountPoint) {
// Propagate original storage scan
return parent::getWatcher($path, $storage);
/** @var IUserMountCache $userMountCache */
$userMountCache = \OC::$server->get(IUserMountCache::class);
$mounts = $userMountCache->getMountsForStorageId($node->getStorageId());
foreach ($mounts as $mount) {
// If the share is originating from an external storage
if ($mount->getMountProvider() === ConfigAdapter::class) {
// Propagate original storage scan
$this->watcher = parent::getWatcher($path, $storage);
return $this->watcher;
}
}
}

// cache updating is handled by the share source
return new NullWatcher();
$this->watcher = new NullWatcher();
return $this->watcher;
}

/**
Expand Down

0 comments on commit ef8cf53

Please sign in to comment.