diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 4da56c9527d9b..327f670afa39b 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -32,30 +32,27 @@ class AmazonS3 extends Common { private LoggerInterface $logger; - public function needsPartFile(): bool { - return false; - } - /** @var CappedMemoryCache */ private CappedMemoryCache $objectCache; - /** @var CappedMemoryCache */ private CappedMemoryCache $directoryCache; - /** @var CappedMemoryCache */ private CappedMemoryCache $filesCache; private IMimeTypeDetector $mimeDetector; - private ?bool $versioningEnabled = null; private ICache $memCache; + private ?bool $versioningEnabled = null; public function __construct(array $parameters) { parent::__construct($parameters); $this->parseParams($parameters); + // @todo: using `key` here may be problematic with different authentication methods and/or key rotation... $this->id = 'amazon::external::' . md5($this->params['hostname'] . ':' . $this->params['bucket'] . ':' . $this->params['key']); + $this->objectCache = new CappedMemoryCache(); $this->directoryCache = new CappedMemoryCache(); $this->filesCache = new CappedMemoryCache(); + $this->mimeDetector = Server::get(IMimeTypeDetector::class); /** @var ICacheFactory $cacheFactory */ $cacheFactory = Server::get(ICacheFactory::class); @@ -66,7 +63,7 @@ public function __construct(array $parameters) { private function normalizePath(string $path): string { $path = trim($path, '/'); - if (!$path) { + if ($path === '') { $path = '.'; } @@ -742,6 +739,11 @@ public function hasUpdated(string $path, int $time): bool { } } + public function needsPartFile(): bool { + // handled natively by the S3 backend/client integration + return false; + } + public function writeStream(string $path, $stream, ?int $size = null): int { if ($size === null) { $size = 0; diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index a28475e0e4b1a..4555e13863dd5 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -130,7 +130,7 @@ private function normalizePath(string $path): string { $path = str_replace('//', '/', $path); // dirname('/folder') returns '.' but internally (in the cache) we store the root as '' - if (!$path || $path === '.') { + if ($path === '.') { $path = ''; } diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php index 9107d99cd6738..091f8b69a6e2e 100644 --- a/tests/lib/Files/Storage/Storage.php +++ b/tests/lib/Files/Storage/Storage.php @@ -116,6 +116,10 @@ public static function fileNameProvider(): array { ['file with space.txt'], ['spéciäl fäile'], ['test single\'quote.txt'], + /*['0'],*/ // disabled until upstream aws-sdk is patched + ['#'], + ['%'], + ['%20'], ]; } @@ -127,6 +131,10 @@ public static function directoryProvider(): array { ['folder with space'], ['spéciäl földer'], ['test single\'quote'], + /*['0'],*/ // disabled until upstream aws-sdk is patched + ['#'], + ['%'], + ['%20'], ]; }