3030use OC \Files \Filesystem ;
3131use OC \Files \ObjectStore \ObjectStoreStorage ;
3232use OC \Files \View ;
33+ use OC \Memcache \Memcached ;
34+ use OC \Memcache \Redis ;
3335use OC_Hook ;
3436use OCA \DAV \Connector \Sabre \Directory ;
3537use OCA \DAV \Connector \Sabre \File ;
4042use OCP \Files \StorageInvalidException ;
4143use OCP \ICache ;
4244use OCP \ICacheFactory ;
45+ use OCP \IConfig ;
4346use OCP \Lock \ILockingProvider ;
4447use Sabre \DAV \Exception \BadRequest ;
4548use 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