Skip to content
Open
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
18 changes: 10 additions & 8 deletions apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,27 @@ class AmazonS3 extends Common {

private LoggerInterface $logger;

public function needsPartFile(): bool {
return false;
}

/** @var CappedMemoryCache<array|false> */
private CappedMemoryCache $objectCache;

/** @var CappedMemoryCache<bool> */
private CappedMemoryCache $directoryCache;

/** @var CappedMemoryCache<array> */
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);
Expand All @@ -66,7 +63,7 @@ public function __construct(array $parameters) {
private function normalizePath(string $path): string {
$path = trim($path, '/');

if (!$path) {
if ($path === '') {
$path = '.';
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
}

Expand Down
8 changes: 8 additions & 0 deletions tests/lib/Files/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];
}

Expand All @@ -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'],
];
}

Expand Down
Loading