Skip to content
Open
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
10 changes: 7 additions & 3 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@
*/
protected array $partial = [];
protected string $storageId;
protected Storage $storageCache;
protected ?Storage $storageCache = null;
protected IMimeTypeLoader $mimetypeLoader;
protected IDBConnection $connection;
protected SystemConfig $systemConfig;
protected LoggerInterface $logger;
protected QuerySearchHelper $querySearchHelper;
protected IEventDispatcher $eventDispatcher;
protected IFilesMetadataManager $metadataManager;
private CacheDependencies $cacheDependencies;

public function __construct(
private IStorage $storage,
Expand All @@ -84,7 +85,7 @@
if (!$dependencies) {
$dependencies = Server::get(CacheDependencies::class);
}
$this->storageCache = new Storage($this->storage, true, $dependencies->getConnection());
$this->cacheDependencies = $dependencies;
$this->mimetypeLoader = $dependencies->getMimeTypeLoader();
$this->connection = $dependencies->getConnection();
$this->systemConfig = $dependencies->getSystemConfig();
Expand All @@ -101,8 +102,8 @@
);
}

public function getStorageCache(): Storage {

Check failure on line 105 in lib/private/Files/Cache/Cache.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidNullableReturnType

lib/private/Files/Cache/Cache.php:105:37: InvalidNullableReturnType: The declared return type 'OC\Files\Cache\Storage' for OC\Files\Cache\Cache::getStorageCache is not nullable, but 'OC\Files\Cache\Storage|null' contains null (see https://psalm.dev/144)
return $this->storageCache;

Check failure on line 106 in lib/private/Files/Cache/Cache.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

NullableReturnStatement

lib/private/Files/Cache/Cache.php:106:10: NullableReturnStatement: The declared return type 'OC\Files\Cache\Storage' for OC\Files\Cache\Cache::getStorageCache is not nullable, but the function returns 'OC\Files\Cache\Storage|null' (see https://psalm.dev/139)
}

/**
Expand All @@ -111,7 +112,10 @@
* @return int
*/
public function getNumericStorageId() {
return $this->storageCache->getNumericId();
if (!$this->storageCache) {
$this->storageCache = new Storage($this->storage, true, $this->cacheDependencies->getConnection());
}
return $this->getStorageCache()->getNumericId();
}

/**
Expand Down
Loading