diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php index 82b7af5a9344b..c003537482493 100644 --- a/apps/files_trashbin/lib/Storage.php +++ b/apps/files_trashbin/lib/Storage.php @@ -53,10 +53,10 @@ public function unlink(string $path): bool { "Can't move file " . $path . ' to the trash bin, therefore it was deleted right away'); - return $this->storage->unlink($path); + return $this->getWrapperStorage()->unlink($path); } } else { - return $this->storage->unlink($path); + return $this->getWrapperStorage()->unlink($path); } } @@ -64,7 +64,7 @@ public function rmdir(string $path): bool { if ($this->trashEnabled) { return $this->doDelete($path, 'rmdir'); } else { - return $this->storage->rmdir($path); + return $this->getWrapperStorage()->rmdir($path); } } @@ -80,9 +80,9 @@ protected function shouldMoveToTrash(string $path): bool { } // check if there is a app which want to disable the trash bin for this file - $fileId = $this->storage->getCache()->getId($path); - $owner = $this->storage->getOwner($path); - if ($owner === false || $this->storage->instanceOfStorage(\OCA\Files_Sharing\External\Storage::class)) { + $fileId = $this->getWrapperStorage()->getCache()->getId($path); + $owner = $this->getWrapperStorage()->getOwner($path); + if ($owner === false || $this->getWrapperStorage()->instanceOfStorage(\OCA\Files_Sharing\External\Storage::class)) { $nodes = $this->rootFolder->getById($fileId); } else { $nodes = $this->rootFolder->getUserFolder($owner)->getById($fileId); @@ -142,7 +142,7 @@ private function doDelete(string $path, string $method): bool { } } - return call_user_func([$this->storage, $method], $path); + return call_user_func([$this->getWrapperStorage(), $method], $path); } /** diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 08a60a127910b..854a28efc2cb7 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -23,11 +23,11 @@ class Encoding extends Wrapper { private CappedMemoryCache $namesCache; /** - * @param array $parameters + * @param array{storage: IStorage, ...} $parameters */ public function __construct(array $parameters) { - $this->storage = $parameters['storage']; $this->namesCache = new CappedMemoryCache(); + parent::__construct($parameters); } /** @@ -74,7 +74,7 @@ private function findPathToUse(string $fullPath): string { */ private function findPathToUseLastSection(string $basePath, string $lastSection): ?string { $fullPath = $basePath . $lastSection; - if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) { + if ($lastSection === '' || $this->isAscii($lastSection) || $this->getWrapperStorage()->file_exists($fullPath)) { $this->namesCache[$fullPath] = $fullPath; return $fullPath; } @@ -86,7 +86,7 @@ private function findPathToUseLastSection(string $basePath, string $lastSection) $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C); } $otherFullPath = $basePath . $otherFormPath; - if ($this->storage->file_exists($otherFullPath)) { + if ($this->getWrapperStorage()->file_exists($otherFullPath)) { $this->namesCache[$fullPath] = $otherFullPath; return $otherFullPath; } @@ -98,7 +98,7 @@ private function findPathToUseLastSection(string $basePath, string $lastSection) public function mkdir(string $path): bool { // note: no conversion here, method should not be called with non-NFC names! - $result = $this->storage->mkdir($path); + $result = $this->getWrapperStorage()->mkdir($path); if ($result) { $this->namesCache[$path] = $path; } @@ -106,7 +106,7 @@ public function mkdir(string $path): bool { } public function rmdir(string $path): bool { - $result = $this->storage->rmdir($this->findPathToUse($path)); + $result = $this->getWrapperStorage()->rmdir($this->findPathToUse($path)); if ($result) { unset($this->namesCache[$path]); } @@ -114,72 +114,72 @@ public function rmdir(string $path): bool { } public function opendir(string $path) { - $handle = $this->storage->opendir($this->findPathToUse($path)); + $handle = $this->getWrapperStorage()->opendir($this->findPathToUse($path)); return EncodingDirectoryWrapper::wrap($handle); } public function is_dir(string $path): bool { - return $this->storage->is_dir($this->findPathToUse($path)); + return $this->getWrapperStorage()->is_dir($this->findPathToUse($path)); } public function is_file(string $path): bool { - return $this->storage->is_file($this->findPathToUse($path)); + return $this->getWrapperStorage()->is_file($this->findPathToUse($path)); } public function stat(string $path): array|false { - return $this->storage->stat($this->findPathToUse($path)); + return $this->getWrapperStorage()->stat($this->findPathToUse($path)); } public function filetype(string $path): string|false { - return $this->storage->filetype($this->findPathToUse($path)); + return $this->getWrapperStorage()->filetype($this->findPathToUse($path)); } public function filesize(string $path): int|float|false { - return $this->storage->filesize($this->findPathToUse($path)); + return $this->getWrapperStorage()->filesize($this->findPathToUse($path)); } public function isCreatable(string $path): bool { - return $this->storage->isCreatable($this->findPathToUse($path)); + return $this->getWrapperStorage()->isCreatable($this->findPathToUse($path)); } public function isReadable(string $path): bool { - return $this->storage->isReadable($this->findPathToUse($path)); + return $this->getWrapperStorage()->isReadable($this->findPathToUse($path)); } public function isUpdatable(string $path): bool { - return $this->storage->isUpdatable($this->findPathToUse($path)); + return $this->getWrapperStorage()->isUpdatable($this->findPathToUse($path)); } public function isDeletable(string $path): bool { - return $this->storage->isDeletable($this->findPathToUse($path)); + return $this->getWrapperStorage()->isDeletable($this->findPathToUse($path)); } public function isSharable(string $path): bool { - return $this->storage->isSharable($this->findPathToUse($path)); + return $this->getWrapperStorage()->isSharable($this->findPathToUse($path)); } public function getPermissions(string $path): int { - return $this->storage->getPermissions($this->findPathToUse($path)); + return $this->getWrapperStorage()->getPermissions($this->findPathToUse($path)); } public function file_exists(string $path): bool { - return $this->storage->file_exists($this->findPathToUse($path)); + return $this->getWrapperStorage()->file_exists($this->findPathToUse($path)); } public function filemtime(string $path): int|false { - return $this->storage->filemtime($this->findPathToUse($path)); + return $this->getWrapperStorage()->filemtime($this->findPathToUse($path)); } public function file_get_contents(string $path): string|false { - return $this->storage->file_get_contents($this->findPathToUse($path)); + return $this->getWrapperStorage()->file_get_contents($this->findPathToUse($path)); } public function file_put_contents(string $path, mixed $data): int|float|false { - return $this->storage->file_put_contents($this->findPathToUse($path), $data); + return $this->getWrapperStorage()->file_put_contents($this->findPathToUse($path), $data); } public function unlink(string $path): bool { - $result = $this->storage->unlink($this->findPathToUse($path)); + $result = $this->getWrapperStorage()->unlink($this->findPathToUse($path)); if ($result) { unset($this->namesCache[$path]); } @@ -188,15 +188,15 @@ public function unlink(string $path): bool { public function rename(string $source, string $target): bool { // second name always NFC - return $this->storage->rename($this->findPathToUse($source), $this->findPathToUse($target)); + return $this->getWrapperStorage()->rename($this->findPathToUse($source), $this->findPathToUse($target)); } public function copy(string $source, string $target): bool { - return $this->storage->copy($this->findPathToUse($source), $this->findPathToUse($target)); + return $this->getWrapperStorage()->copy($this->findPathToUse($source), $this->findPathToUse($target)); } public function fopen(string $path, string $mode) { - $result = $this->storage->fopen($this->findPathToUse($path), $mode); + $result = $this->getWrapperStorage()->fopen($this->findPathToUse($path), $mode); if ($result && $mode !== 'r' && $mode !== 'rb') { unset($this->namesCache[$path]); } @@ -204,45 +204,45 @@ public function fopen(string $path, string $mode) { } public function getMimeType(string $path): string|false { - return $this->storage->getMimeType($this->findPathToUse($path)); + return $this->getWrapperStorage()->getMimeType($this->findPathToUse($path)); } public function hash(string $type, string $path, bool $raw = false): string|false { - return $this->storage->hash($type, $this->findPathToUse($path), $raw); + return $this->getWrapperStorage()->hash($type, $this->findPathToUse($path), $raw); } public function free_space(string $path): int|float|false { - return $this->storage->free_space($this->findPathToUse($path)); + return $this->getWrapperStorage()->free_space($this->findPathToUse($path)); } public function touch(string $path, ?int $mtime = null): bool { - return $this->storage->touch($this->findPathToUse($path), $mtime); + return $this->getWrapperStorage()->touch($this->findPathToUse($path), $mtime); } public function getLocalFile(string $path): string|false { - return $this->storage->getLocalFile($this->findPathToUse($path)); + return $this->getWrapperStorage()->getLocalFile($this->findPathToUse($path)); } public function hasUpdated(string $path, int $time): bool { - return $this->storage->hasUpdated($this->findPathToUse($path), $time); + return $this->getWrapperStorage()->hasUpdated($this->findPathToUse($path), $time); } public function getCache(string $path = '', ?IStorage $storage = null): ICache { if (!$storage) { $storage = $this; } - return $this->storage->getCache($this->findPathToUse($path), $storage); + return $this->getWrapperStorage()->getCache($this->findPathToUse($path), $storage); } public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { $storage = $this; } - return $this->storage->getScanner($this->findPathToUse($path), $storage); + return $this->getWrapperStorage()->getScanner($this->findPathToUse($path), $storage); } public function getETag(string $path): string|false { - return $this->storage->getETag($this->findPathToUse($path)); + return $this->getWrapperStorage()->getETag($this->findPathToUse($path)); } public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { @@ -250,7 +250,7 @@ public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalP return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath)); } - $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); + $result = $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); if ($result) { unset($this->namesCache[$targetInternalPath]); } @@ -267,7 +267,7 @@ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalP return $result; } - $result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); + $result = $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); if ($result) { unset($this->namesCache[$sourceInternalPath]); unset($this->namesCache[$targetInternalPath]); @@ -276,7 +276,7 @@ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalP } public function getMetaData(string $path): ?array { - $entry = $this->storage->getMetaData($this->findPathToUse($path)); + $entry = $this->getWrapperStorage()->getMetaData($this->findPathToUse($path)); if ($entry !== null) { $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); } @@ -284,7 +284,7 @@ public function getMetaData(string $path): ?array { } public function getDirectoryContent(string $directory): \Traversable { - $entries = $this->storage->getDirectoryContent($this->findPathToUse($directory)); + $entries = $this->getWrapperStorage()->getDirectoryContent($this->findPathToUse($directory)); foreach ($entries as $entry) { $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); yield $entry; diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 0af619cc23261..194c57a4191cd 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -42,7 +42,7 @@ class Encryption extends Wrapper { private bool $enabled = true; /** - * @param array $parameters + * @param array{storage: Storage\IStorage, ...} $parameters */ public function __construct( array $parameters, @@ -67,7 +67,7 @@ public function filesize(string $path): int|float|false { $info = $this->getCache()->get($path); if ($info === false) { /* Pass call to wrapped storage, it may be a special file like a part file */ - return $this->storage->filesize($path); + return $this->getWrapperStorage()->filesize($path); } if (isset($this->unencryptedSize[$fullPath])) { $size = $this->unencryptedSize[$fullPath]; @@ -102,7 +102,7 @@ public function filesize(string $path): int|float|false { return $this->verifyUnencryptedSize($path, $info->getUnencryptedSize()); } - return $this->storage->filesize($path); + return $this->getWrapperStorage()->filesize($path); } private function modifyMetaData(string $path, array $data): array { @@ -129,7 +129,7 @@ private function modifyMetaData(string $path, array $data): array { } public function getMetaData(string $path): ?array { - $data = $this->storage->getMetaData($path); + $data = $this->getWrapperStorage()->getMetaData($path); if (is_null($data)) { return null; } @@ -155,7 +155,7 @@ public function file_get_contents(string $path): string|false { fclose($handle); return $data; } - return $this->storage->file_get_contents($path); + return $this->getWrapperStorage()->file_get_contents($path); } public function file_put_contents(string $path, mixed $data): int|float|false { @@ -173,7 +173,7 @@ public function file_put_contents(string $path, mixed $data): int|float|false { public function unlink(string $path): bool { $fullPath = $this->getFullPath($path); if ($this->util->isExcluded($fullPath)) { - return $this->storage->unlink($path); + return $this->getWrapperStorage()->unlink($path); } $encryptionModule = $this->getEncryptionModule($path); @@ -181,11 +181,11 @@ public function unlink(string $path): bool { $this->keyStorage->deleteAllFileKeys($fullPath); } - return $this->storage->unlink($path); + return $this->getWrapperStorage()->unlink($path); } public function rename(string $source, string $target): bool { - $result = $this->storage->rename($source, $target); + $result = $this->getWrapperStorage()->rename($source, $target); if ($result // versions always use the keys from the original file, so we can skip @@ -210,7 +210,7 @@ public function rename(string $source, string $target): bool { } public function rmdir(string $path): bool { - $result = $this->storage->rmdir($path); + $result = $this->getWrapperStorage()->rmdir($path); $fullPath = $this->getFullPath($path); if ($result && $this->util->isExcluded($fullPath) === false @@ -236,14 +236,14 @@ public function isReadable(string $path): bool { $isReadable = $module->isReadable($fullPath, $this->uid); } - return $this->storage->isReadable($path) && $isReadable; + return $this->getWrapperStorage()->isReadable($path) && $isReadable; } public function copy(string $source, string $target): bool { $sourcePath = $this->getFullPath($source); if ($this->util->isExcluded($sourcePath)) { - return $this->storage->copy($source, $target); + return $this->getWrapperStorage()->copy($source, $target); } // need to stream copy file by file in case we copy between a encrypted @@ -258,11 +258,11 @@ public function fopen(string $path, string $mode) { // decrypt it if ($this->arrayCache->hasKey('encryption_copy_version_' . $path)) { $this->arrayCache->remove('encryption_copy_version_' . $path); - return $this->storage->fopen($path, $mode); + return $this->getWrapperStorage()->fopen($path, $mode); } if (!$this->enabled) { - return $this->storage->fopen($path, $mode); + return $this->getWrapperStorage()->fopen($path, $mode); } $encryptionEnabled = $this->encryptionManager->isEnabled(); @@ -288,7 +288,7 @@ public function fopen(string $path, string $mode) { } if ($this->file_exists($path)) { - $size = $this->storage->filesize($path); + $size = $this->getWrapperStorage()->filesize($path); $unencryptedSize = $this->filesize($path); } else { $size = $unencryptedSize = 0; @@ -304,7 +304,7 @@ public function fopen(string $path, string $mode) { ) { // if we update a encrypted file with a un-encrypted one we change the db flag if ($targetIsEncrypted && $encryptionEnabled === false) { - $cache = $this->storage->getCache(); + $cache = $this->getWrapperStorage()->getCache(); $entry = $cache->get($path); $cache->update($entry->getId(), ['encrypted' => 0]); } @@ -357,19 +357,19 @@ public function fopen(string $path, string $mode) { throw new InvalidHeaderException("Unable to get header size for $path, even though file does start with encryption header"); } } - $source = $this->storage->fopen($path, $mode); + $source = $this->getWrapperStorage()->fopen($path, $mode); if (!is_resource($source)) { return false; } $handle = \OC\Files\Stream\Encryption::wrap($source, $path, $fullPath, $header, - $this->uid, $encryptionModule, $this->storage, $this, $this->util, $this->fileHelper, $mode, + $this->uid, $encryptionModule, $this->getWrapperStorage(), $this, $this->util, $this->fileHelper, $mode, $size, $unencryptedSize, $headerSize, $signed); return $handle; } } - return $this->storage->fopen($path, $mode); + return $this->getWrapperStorage()->fopen($path, $mode); } @@ -383,7 +383,7 @@ public function fopen(string $path, string $mode) { * @return int unencrypted size */ protected function verifyUnencryptedSize(string $path, int $unencryptedSize): int { - $size = $this->storage->filesize($path); + $size = $this->getWrapperStorage()->filesize($path); $result = $unencryptedSize; if ($unencryptedSize < 0 @@ -418,7 +418,7 @@ protected function fixUnencryptedSize(string $path, int $size, int $unencryptedS $header = $this->getHeader($path); $encryptionModule = $this->getEncryptionModule($path); - $stream = $this->storage->fopen($path, 'r'); + $stream = $this->getWrapperStorage()->fopen($path, 'r'); // if we couldn't open the file we return the old unencrypted size if (!is_resource($stream)) { @@ -482,7 +482,7 @@ protected function fixUnencryptedSize(string $path, int $size, int $unencryptedS $this->updateUnencryptedSize($this->getFullPath($path), $newUnencryptedSize); // write to cache if applicable - $cache = $this->storage->getCache(); + $cache = $this->getWrapperStorage()->getCache(); $entry = $cache->get($path); $cache->update($entry['fileid'], [ 'unencrypted_size' => $newUnencryptedSize @@ -529,7 +529,7 @@ public function moveFromStorage( } // TODO clean this up once the underlying moveFromStorage in OC\Files\Storage\Wrapper\Common is fixed: - // - call $this->storage->moveFromStorage() instead of $this->copyBetweenStorage + // - call $this->getWrapperStorage()->moveFromStorage() instead of $this->copyBetweenStorage // - copy the file cache update from $this->copyBetweenStorage to this method // - copy the copyKeys() call from $this->copyBetweenStorage to this method // - remove $this->copyBetweenStorage @@ -569,7 +569,7 @@ public function copyFromStorage( $isRename = false, ): bool { // TODO clean this up once the underlying moveFromStorage in OC\Files\Storage\Wrapper\Common is fixed: - // - call $this->storage->copyFromStorage() instead of $this->copyBetweenStorage + // - call $this->getWrapperStorage()->copyFromStorage() instead of $this->copyBetweenStorage // - copy the file cache update from $this->copyBetweenStorage to this method // - copy the copyKeys() call from $this->copyBetweenStorage to this method // - remove $this->copyBetweenStorage @@ -643,7 +643,7 @@ private function copyBetweenStorage( // fopen($sourceInternalPath) and by-pass the encryption in order to // create a 1:1 copy of the file $this->arrayCache->set('encryption_copy_version_' . $sourceInternalPath, true); - $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + $result = $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); $this->arrayCache->remove('encryption_copy_version_' . $sourceInternalPath); if ($result) { $info = $this->getCache('', $sourceStorage)->get($sourceInternalPath); @@ -728,18 +728,18 @@ public function getLocalFile(string $path): string|false { return $cachedFile; } } - return $this->storage->getLocalFile($path); + return $this->getWrapperStorage()->getLocalFile($path); } public function isLocal(): bool { if ($this->encryptionManager->isEnabled()) { return false; } - return $this->storage->isLocal(); + return $this->getWrapperStorage()->isLocal(); } public function stat(string $path): array|false { - $stat = $this->storage->stat($path); + $stat = $this->getWrapperStorage()->stat($path); if (!$stat) { return false; } @@ -777,8 +777,8 @@ protected function getFullPath(string $path): string { */ protected function readFirstBlock(string $path): string { $firstBlock = ''; - if ($this->storage->is_file($path)) { - $handle = $this->storage->fopen($path, 'r'); + if ($this->getWrapperStorage()->is_file($path)) { + $handle = $this->getWrapperStorage()->fopen($path, 'r'); if ($handle === false) { return ''; } @@ -794,7 +794,7 @@ protected function readFirstBlock(string $path): string { protected function getHeaderSize(string $path): int { $headerSize = 0; $realFile = $this->util->stripPartialFileExtension($path); - if ($this->storage->is_file($realFile)) { + if ($this->getWrapperStorage()->is_file($realFile)) { $path = $realFile; } $firstBlock = $this->readFirstBlock($path); @@ -811,7 +811,7 @@ protected function getHeaderSize(string $path): int { */ protected function getHeader(string $path): array { $realFile = $this->util->stripPartialFileExtension($path); - $exists = $this->storage->is_file($realFile); + $exists = $this->getWrapperStorage()->is_file($realFile); if ($exists) { $path = $realFile; } diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php index 66864ba9ef3b3..e67885b4397d2 100644 --- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php @@ -28,7 +28,7 @@ class PermissionsMask extends Wrapper { protected readonly int $mask; /** - * @param array{storage: Storage, mask: int, ...} $parameters + * @param array{storage: IStorage, mask: int, ...} $parameters * * $storage: The storage the permissions mask should be applied on * $mask: The permission bits that should be kept, a combination of the \OCP\Constant::PERMISSION_ constants @@ -59,7 +59,7 @@ public function isSharable(string $path): bool { } public function getPermissions(string $path): int { - return $this->storage->getPermissions($path) & $this->mask; + return $this->getWrapperStorage()->getPermissions($path) & $this->mask; } public function rename(string $source, string $target): bool { @@ -125,7 +125,7 @@ public function getMetaData(string $path): ?array { public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { - $storage = $this->storage; + $storage = $this->getWrapperStorage(); } return parent::getScanner($path, $storage); } diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index 35a265f8c8e72..ce0de5bb71117 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -73,16 +73,16 @@ protected function getSize(string $path, ?IStorage $storage = null): int|float { public function free_space(string $path): int|float|false { if (!$this->hasQuota()) { - return $this->storage->free_space($path); + return $this->getWrapperStorage()->free_space($path); } if ($this->getQuota() < 0 || str_starts_with($path, 'cache') || str_starts_with($path, 'uploads')) { - return $this->storage->free_space($path); + return $this->getWrapperStorage()->free_space($path); } else { $used = $this->getSize($this->sizeRoot); if ($used < 0) { return FileInfo::SPACE_NOT_COMPUTED; } else { - $free = $this->storage->free_space($path); + $free = $this->getWrapperStorage()->free_space($path); $quotaFree = max($this->getQuota() - $used, 0); // if free space is known $free = $free >= 0 ? min($free, $quotaFree) : $quotaFree; @@ -93,11 +93,11 @@ public function free_space(string $path): int|float|false { public function file_put_contents(string $path, mixed $data): int|float|false { if (!$this->hasQuota()) { - return $this->storage->file_put_contents($path, $data); + return $this->getWrapperStorage()->file_put_contents($path, $data); } $free = $this->free_space($path); if ($free < 0 || strlen($data) < $free) { - return $this->storage->file_put_contents($path, $data); + return $this->getWrapperStorage()->file_put_contents($path, $data); } else { return false; } @@ -105,11 +105,11 @@ public function file_put_contents(string $path, mixed $data): int|float|false { public function copy(string $source, string $target): bool { if (!$this->hasQuota()) { - return $this->storage->copy($source, $target); + return $this->getWrapperStorage()->copy($source, $target); } $free = $this->free_space($target); if ($free < 0 || $this->getSize($source) < $free) { - return $this->storage->copy($source, $target); + return $this->getWrapperStorage()->copy($source, $target); } else { return false; } @@ -117,9 +117,9 @@ public function copy(string $source, string $target): bool { public function fopen(string $path, string $mode) { if (!$this->hasQuota()) { - return $this->storage->fopen($path, $mode); + return $this->getWrapperStorage()->fopen($path, $mode); } - $source = $this->storage->fopen($path, $mode); + $source = $this->getWrapperStorage()->fopen($path, $mode); // don't apply quota for part files if (!$this->isPartFile($path)) { @@ -156,11 +156,11 @@ protected function shouldApplyQuota(string $path): bool { public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if (!$this->hasQuota()) { - return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } $free = $this->free_space($targetInternalPath); if ($free < 0 || $this->getSize($sourceInternalPath, $sourceStorage) < $free) { - return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } else { return false; } @@ -168,11 +168,11 @@ public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalP public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if (!$this->hasQuota()) { - return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } $free = $this->free_space($targetInternalPath); if ($free < 0 || $this->getSize($sourceInternalPath, $sourceStorage) < $free) { - return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } else { return false; } @@ -180,7 +180,7 @@ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalP public function mkdir(string $path): bool { if (!$this->hasQuota()) { - return $this->storage->mkdir($path); + return $this->getWrapperStorage()->mkdir($path); } $free = $this->free_space($path); if ($this->shouldApplyQuota($path) && $free == 0) { @@ -192,7 +192,7 @@ public function mkdir(string $path): bool { public function touch(string $path, ?int $mtime = null): bool { if (!$this->hasQuota()) { - return $this->storage->touch($path, $mtime); + return $this->getWrapperStorage()->touch($path, $mtime); } $free = $this->free_space($path); if ($free == 0) { diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 22d1e8eea3665..d9928626ed1c7 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -26,7 +26,7 @@ use Psr\Log\LoggerInterface; class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { - protected ?Storage $storage = null; + protected ?IStorage $storage = null; public ?ICache $cache = null; @@ -39,7 +39,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { public ?IUpdater $updater = null; /** - * @param array{storage: Storage, ...} $parameters + * @param array{storage: IStorage, ...} $parameters */ public function __construct(array $parameters) { $this->storage = $parameters['storage'];