diff options
-rw-r--r-- | apps/files_sharing/lib/Updater.php | 2 | ||||
-rw-r--r-- | lib/private/Cache/CappedMemoryCache.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Filesystem.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Mount/Manager.php | 8 | ||||
-rw-r--r-- | lib/private/Files/Node/Root.php | 10 | ||||
-rw-r--r-- | lib/private/Files/SetupManager.php | 6 | ||||
-rw-r--r-- | lib/private/Files/View.php | 16 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/FilesystemTornDownEvent.php | 2 | ||||
-rw-r--r-- | tests/lib/Files/Mount/ManagerTest.php | 4 |
9 files changed, 23 insertions, 45 deletions
diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 9ce114f495d..ad194dde016 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -26,6 +26,7 @@ */ namespace OCA\Files_Sharing; +use OC\Files\Mount\MountPoint; use OCP\Constants; use OCP\Share\IShare; @@ -105,6 +106,7 @@ class Updater { $mountManager = \OC\Files\Filesystem::getMountManager(); $mountedShares = $mountManager->findIn('/' . \OC_User::getUser() . '/files/' . $oldPath); foreach ($mountedShares as $mount) { + /** @var MountPoint $mount */ if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) { $mountPoint = $mount->getMountPoint(); $target = str_replace($absOldPath, $absNewPath, $mountPoint); diff --git a/lib/private/Cache/CappedMemoryCache.php b/lib/private/Cache/CappedMemoryCache.php index dd7cb32e90f..9260bf1f6b3 100644 --- a/lib/private/Cache/CappedMemoryCache.php +++ b/lib/private/Cache/CappedMemoryCache.php @@ -51,7 +51,7 @@ class CappedMemoryCache implements ICache, \ArrayAccess { /** * @param string $key - * @param T$value + * @param T $value * @param int $ttl * @return bool */ @@ -89,7 +89,7 @@ class CappedMemoryCache implements ICache, \ArrayAccess { /** * @param string $key - * @param T$value + * @param T $value * @return void */ public function offsetSet($offset, $value): void { diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index b392b1aa3cb..1aedad93aa1 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -38,16 +38,12 @@ namespace OC\Files; use OC\Cache\CappedMemoryCache; -use OC\Files\Config\MountProviderCollection; use OC\Files\Mount\MountPoint; -use OC\Lockdown\Filesystem\NullStorage; use OC\User\NoUserException; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Config\IMountProvider; use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorageFactory; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; @@ -262,11 +258,7 @@ class Filesystem { \OC_Util::setupFS(); } $mount = self::$mounts->find($path); - if ($mount) { - return $mount->getMountPoint(); - } else { - return ''; - } + return $mount->getMountPoint(); } /** @@ -322,11 +314,7 @@ class Filesystem { */ public static function resolvePath($path) { $mount = self::getMountManager()->find($path); - if ($mount) { - return [$mount->getStorage(), rtrim($mount->getInternalPath($path), '/')]; - } else { - return [null, null]; - } + return [$mount->getStorage(), rtrim($mount->getInternalPath($path), '/')]; } public static function init($user, $root) { diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php index 5544b218658..66832690363 100644 --- a/lib/private/Files/Mount/Manager.php +++ b/lib/private/Files/Mount/Manager.php @@ -105,10 +105,8 @@ class Manager implements IMountManager { if (isset($this->mounts[$mountPoint])) { $this->pathCache[$path] = $this->mounts[$mountPoint]; return $this->mounts[$mountPoint]; - } - - if ($current === '') { - throw new NotFoundException("No mount for path " . $path . " existing mounts: " . implode(",", array_keys($this->mounts))); + } elseif ($current === '') { + break; } $current = dirname($current); @@ -116,6 +114,8 @@ class Manager implements IMountManager { $current = ''; } } + + throw new NotFoundException("No mount for path " . $path . " existing mounts: " . implode(",", array_keys($this->mounts))); } /** diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 4e4dc0ec0de..88ac4a31d34 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -271,21 +271,21 @@ class Root extends Folder implements IRootFolder { * @return int */ public function getId() { - return null; + return 0; } /** * @return array */ public function stat() { - return null; + return []; } /** * @return int */ public function getMTime() { - return null; + return 0; } /** @@ -293,14 +293,14 @@ class Root extends Folder implements IRootFolder { * @return int */ public function getSize($includeMounts = true) { - return null; + return 0; } /** * @return string */ public function getEtag() { - return null; + return ''; } /** diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index 853c50884a2..f9276ef4171 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -41,13 +41,11 @@ use OCP\Constants; use OCP\Diagnostics\IEventLogger; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\IMountProvider; -use OCP\Files\Config\IMountProviderCollection; use OCP\Files\Config\IUserMountCache; use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage\IStorage; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\Lockdown\ILockdownManager; @@ -55,7 +53,7 @@ use OCP\Lockdown\ILockdownManager; class SetupManager { private bool $rootSetup = false; private IEventLogger $eventLogger; - private IMountProviderCollection $mountProviderCollection; + private MountProviderCollection $mountProviderCollection; private IMountManager $mountManager; private IUserManager $userManager; private array $setupUsers = []; @@ -66,7 +64,7 @@ class SetupManager { public function __construct( IEventLogger $eventLogger, - IMountProviderCollection $mountProviderCollection, + MountProviderCollection $mountProviderCollection, IMountManager $mountManager, IUserManager $userManager, IEventDispatcher $eventDispatcher, diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 6f96f911785..779e0611591 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -274,7 +274,7 @@ class View { /** * remove mount point * - * @param \OC\Files\Mount\MoveableMount $mount + * @param IMountPoint $mount * @param string $path relative to data/ * @return boolean */ @@ -719,7 +719,7 @@ class View { $postFix = (substr($path, -1) === '/') ? '/' : ''; $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); $mount = Filesystem::getMountManager()->find($absolutePath . $postFix); - if ($mount and $mount->getInternalPath($absolutePath) === '') { + if ($mount->getInternalPath($absolutePath) === '') { return $this->removeMount($mount, $absolutePath); } if ($this->is_dir($path)) { @@ -1383,10 +1383,6 @@ class View { $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path); $mount = Filesystem::getMountManager()->find($path); - if (!$mount) { - \OC::$server->getLogger()->warning('Mountpoint not found for path: ' . $path); - return false; - } $storage = $mount->getStorage(); $internalPath = $mount->getInternalPath($path); if ($storage) { @@ -1488,7 +1484,7 @@ class View { $rootEntry = $subCache->get(''); if (!$rootEntry) { - $subScanner = $subStorage->getScanner(''); + $subScanner = $subStorage->getScanner(); try { $subScanner->scanFile(''); } catch (\OCP\Files\StorageNotAvailableException $e) { @@ -1916,14 +1912,10 @@ class View { * @param string $absolutePath absolute path * @param bool $useParentMount true to return parent mount instead of whatever * is mounted directly on the given path, false otherwise - * @return \OC\Files\Mount\MountPoint mount point for which to apply locks + * @return IMountPoint mount point for which to apply locks */ private function getMountForLock($absolutePath, $useParentMount = false) { - $results = []; $mount = Filesystem::getMountManager()->find($absolutePath); - if (!$mount) { - return $results; - } if ($useParentMount) { // find out if something is mounted directly on the path diff --git a/lib/public/Files/Events/Node/FilesystemTornDownEvent.php b/lib/public/Files/Events/Node/FilesystemTornDownEvent.php index d8e289a0a9f..3e7780c827e 100644 --- a/lib/public/Files/Events/Node/FilesystemTornDownEvent.php +++ b/lib/public/Files/Events/Node/FilesystemTornDownEvent.php @@ -27,6 +27,8 @@ use OCP\EventDispatcher\Event; /** * Event fired after the filesystem has been torn down + * + * @since 24.0.0 */ class FilesystemTornDownEvent extends Event { } diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php index e834d77b73a..f69f8b239bb 100644 --- a/tests/lib/Files/Mount/ManagerTest.php +++ b/tests/lib/Files/Mount/ManagerTest.php @@ -10,10 +10,6 @@ namespace Test\Files\Mount; use OC\Files\SetupManagerFactory; use OC\Files\Storage\Temporary; -use OCP\Diagnostics\IEventLogger; -use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Config\IMountProviderCollection; -use OCP\IUserManager; class LongId extends Temporary { public function getId() { |