mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
fix(Wrapper): Always use getWrapperStorage()
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
7e1401a4bc
commit
5d1e0a6e3a
5 changed files with 91 additions and 91 deletions
|
|
@ -53,10 +53,10 @@ class Storage extends Wrapper {
|
|||
"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 @@ class Storage extends Wrapper {
|
|||
if ($this->trashEnabled) {
|
||||
return $this->doDelete($path, 'rmdir');
|
||||
} else {
|
||||
return $this->storage->rmdir($path);
|
||||
return $this->getWrapperStorage()->rmdir($path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,9 +80,9 @@ class Storage extends Wrapper {
|
|||
}
|
||||
|
||||
// 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 @@ class Storage extends Wrapper {
|
|||
}
|
||||
}
|
||||
|
||||
return call_user_func([$this->storage, $method], $path);
|
||||
return call_user_func([$this->getWrapperStorage(), $method], $path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Encoding extends Wrapper {
|
|||
*/
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
$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 @@ class Encoding extends Wrapper {
|
|||
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
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 @@ class Encoding extends Wrapper {
|
|||
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 @@ class Encoding extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encoding extends Wrapper {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class Encryption extends Wrapper {
|
|||
$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 @@ class Encryption extends Wrapper {
|
|||
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 @@ class Encryption extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encryption extends Wrapper {
|
|||
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 @@ class Encryption extends Wrapper {
|
|||
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 @@ class Encryption extends Wrapper {
|
|||
$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 @@ class Encryption extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encryption extends Wrapper {
|
|||
$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 @@ class Encryption extends Wrapper {
|
|||
// 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 @@ class Encryption extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class Encryption extends Wrapper {
|
|||
) {
|
||||
// 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 @@ class Encryption extends Wrapper {
|
|||
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 @@ class Encryption extends Wrapper {
|
|||
* @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 @@ class Encryption extends Wrapper {
|
|||
$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 @@ class Encryption extends Wrapper {
|
|||
$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 @@ class Encryption extends Wrapper {
|
|||
}
|
||||
|
||||
// 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 @@ class Encryption extends Wrapper {
|
|||
$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 @@ class Encryption extends Wrapper {
|
|||
// 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 @@ class Encryption extends Wrapper {
|
|||
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 @@ class Encryption extends Wrapper {
|
|||
*/
|
||||
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 @@ class Encryption extends Wrapper {
|
|||
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 @@ class Encryption extends Wrapper {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class PermissionsMask extends Wrapper {
|
|||
}
|
||||
|
||||
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 @@ class PermissionsMask extends Wrapper {
|
|||
|
||||
public function getScanner(string $path = '', ?IStorage $storage = null): IScanner {
|
||||
if (!$storage) {
|
||||
$storage = $this->storage;
|
||||
$storage = $this->getWrapperStorage();
|
||||
}
|
||||
return parent::getScanner($path, $storage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,16 +73,16 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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 @@ class Quota extends Wrapper {
|
|||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue