Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions apps/files_trashbin/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ 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);
}
}

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);
}
}

Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down
78 changes: 39 additions & 39 deletions lib/private/Files/Storage/Wrapper/Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -98,88 +98,88 @@ 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;
}
return $result;
}

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]);
}
return $result;
}

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]);
}
Expand All @@ -188,69 +188,69 @@ 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]);
}
return $result;
}

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 {
if ($sourceStorage === $this) {
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]);
}
Expand All @@ -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]);
Expand All @@ -276,15 +276,15 @@ 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']), '/');
}
return $entry;
}

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;
Expand Down
Loading
Loading