diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-09-15 17:14:37 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-09-16 18:11:38 +0200 |
commit | 492e6997d8ed5077c2dd36b690a10eef4beb9324 (patch) | |
tree | 85f295e604fbd1ee2af4e74654f39abdffc31428 /lib/private/Files/Storage | |
parent | f80eda439857e4dca769f77425b6fad2da8a4765 (diff) | |
download | nextcloud-server-492e6997d8ed5077c2dd36b690a10eef4beb9324.tar.gz nextcloud-server-492e6997d8ed5077c2dd36b690a10eef4beb9324.zip |
chore: Fix psalm issues, put back private versions of getter in private Storage interface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Files/Storage')
-rw-r--r-- | lib/private/Files/Storage/Common.php | 20 | ||||
-rw-r--r-- | lib/private/Files/Storage/Home.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Storage/Storage.php | 46 | ||||
-rw-r--r-- | lib/private/Files/Storage/Temporary.php | 2 |
4 files changed, 63 insertions, 9 deletions
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index cefba66683b..01b33648ac0 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -44,14 +44,14 @@ use Psr\Log\LoggerInterface; abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { use LocalTempFileTrait; - protected $cache; - protected $scanner; - protected $watcher; - protected $propagator; + protected ?Cache $cache = null; + protected ?Scanner $scanner = null; + protected ?Watcher $watcher = null; + protected ?Propagator $propagator = null; protected $storageCache; - protected $updater; + protected ?Updater $updater = null; - protected $mountOptions = []; + protected array $mountOptions = []; protected $owner = null; private ?bool $shouldLogLocks = null; @@ -310,13 +310,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $dependencies; } + /** + * @return Cache + */ public function getCache($path = '', $storage = null) { if (!$storage) { $storage = $this; } + /** @psalm-suppress NoInterfaceProperties The isset check is safe */ if (!isset($storage->cache)) { $storage->cache = new Cache($storage, $this->getCacheDependencies()); } + /** @psalm-suppress NullableReturnStatement False-positive, as the if above avoids this being null */ + /** @psalm-suppress NoInterfaceProperties Legacy */ return $storage->cache; } @@ -324,9 +330,11 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { if (!$storage) { $storage = $this; } + /** @psalm-suppress NoInterfaceProperties The isset check is safe */ if (!isset($storage->scanner)) { $storage->scanner = new Scanner($storage); } + /** @psalm-suppress NoInterfaceProperties Legacy stuff */ return $storage->scanner; } diff --git a/lib/private/Files/Storage/Home.php b/lib/private/Files/Storage/Home.php index a8d1f82b987..0e53e7b28d4 100644 --- a/lib/private/Files/Storage/Home.php +++ b/lib/private/Files/Storage/Home.php @@ -52,13 +52,14 @@ class Home extends Local implements \OCP\Files\IHomeStorage { if (!isset($this->cache)) { $this->cache = new \OC\Files\Cache\HomeCache($storage, $this->getCacheDependencies()); } + /** @var \OC\Files\Cache\HomeCache */ return $this->cache; } /** * get a propagator instance for the cache * - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher * @return \OC\Files\Cache\Propagator */ public function getPropagator($storage = null) { @@ -68,6 +69,7 @@ class Home extends Local implements \OCP\Files\IHomeStorage { if (!isset($this->propagator)) { $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); } + /** @var \OC\Files\Cache\Propagator */ return $this->propagator; } diff --git a/lib/private/Files/Storage/Storage.php b/lib/private/Files/Storage/Storage.php index 8f37daaf613..aff914ee12a 100644 --- a/lib/private/Files/Storage/Storage.php +++ b/lib/private/Files/Storage/Storage.php @@ -8,6 +8,7 @@ namespace OC\Files\Storage; +use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\IStorage; /** @@ -15,7 +16,50 @@ use OCP\Files\Storage\IStorage; * * All paths passed to the storage are relative to the storage and should NOT have a leading slash. */ -interface Storage extends IStorage { +interface Storage extends IStorage, ILockingStorage { + /** + * get a cache instance for the storage + * + * @param string $path + * @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache + * @return \OC\Files\Cache\Cache + */ + public function getCache($path = '', $storage = null); + + /** + * get a scanner instance for the storage + * + * @param string $path + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner + * @return \OC\Files\Cache\Scanner + */ + public function getScanner($path = '', $storage = null); + + /** + * get a watcher instance for the cache + * + * @param string $path + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher + * @return \OC\Files\Cache\Watcher + */ + public function getWatcher($path = '', $storage = null); + + /** + * get a propagator instance for the cache + * + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher + * @return \OC\Files\Cache\Propagator + */ + public function getPropagator($storage = null); + + /** + * get a updater instance for the cache + * + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher + * @return \OC\Files\Cache\Updater + */ + public function getUpdater($storage = null); + /** * @return \OC\Files\Cache\Storage */ diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index 95ae84cb7d9..6c7ef4260c1 100644 --- a/lib/private/Files/Storage/Temporary.php +++ b/lib/private/Files/Storage/Temporary.php @@ -11,7 +11,7 @@ namespace OC\Files\Storage; * local storage backend in temporary folder for testing purpose */ class Temporary extends Local { - public function __construct($arguments = null) { + public function __construct($arguments = []) { parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); } |