Skip to content

Commit 3374457

Browse files
authored
Merge pull request #41371 from nextcloud/backport/41354/stable27
[stable27] fix: Validate that we have a proper distributed cache configured
2 parents a2c8a0b + f81aa80 commit 3374457

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

apps/dav/lib/Upload/ChunkingV2Plugin.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
use OC\Files\Filesystem;
3131
use OC\Files\ObjectStore\ObjectStoreStorage;
3232
use OC\Files\View;
33+
use OC\Memcache\Memcached;
34+
use OC\Memcache\Redis;
3335
use OC_Hook;
3436
use OCA\DAV\Connector\Sabre\Directory;
3537
use OCA\DAV\Connector\Sabre\File;
@@ -40,6 +42,7 @@
4042
use OCP\Files\StorageInvalidException;
4143
use OCP\ICache;
4244
use OCP\ICacheFactory;
45+
use OCP\IConfig;
4346
use OCP\Lock\ILockingProvider;
4447
use Sabre\DAV\Exception\BadRequest;
4548
use Sabre\DAV\Exception\InsufficientStorage;
@@ -272,6 +275,11 @@ public function beforeDelete(RequestInterface $request, ResponseInterface $respo
272275
* @throws StorageInvalidException
273276
*/
274277
private function checkPrerequisites(bool $checkUploadMetadata = true): void {
278+
$distributedCacheConfig = \OCP\Server::get(IConfig::class)->getSystemValue('memcache.distributed', null);
279+
280+
if ($distributedCacheConfig === null || (!$this->cache instanceof Redis && !$this->cache instanceof Memcached)) {
281+
throw new BadRequest('Skipping chunking v2 since no proper distributed cache is available');
282+
}
275283
if (!$this->uploadFolder instanceof UploadFolder || empty($this->server->httpRequest->getHeader(self::DESTINATION_HEADER))) {
276284
throw new BadRequest('Skipping chunked file writing as the destination header was not passed');
277285
}
@@ -284,7 +292,7 @@ private function checkPrerequisites(bool $checkUploadMetadata = true): void {
284292

285293
if ($checkUploadMetadata) {
286294
if ($this->uploadId === null || $this->uploadPath === null) {
287-
throw new PreconditionFailed('Missing metadata for chunked upload');
295+
throw new PreconditionFailed('Missing metadata for chunked upload. The distributed cache does not hold the information of previous requests.');
288296
}
289297
}
290298
}

0 commit comments

Comments
 (0)