]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make X-HAS-{MD5/SHA256} opt-in 32758/head
authorCarl Schwan <carl@carlschwan.eu>
Wed, 1 Jun 2022 08:59:04 +0000 (10:59 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Wed, 8 Jun 2022 11:39:30 +0000 (13:39 +0200)
This is not always needed and slow down the upload

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
(cherry picked from commit 1b426eda44f59648d2f1c5b79a06c78ff74c9fce)

apps/dav/lib/Connector/Sabre/File.php

index 6c37998499524f96e2f367e7f1d60c5db139adc1..00c7c779eee1c0dec19e3d0f7ef9cb1292e4bc83 100644 (file)
@@ -215,15 +215,26 @@ class File extends Node implements IFile {
                                $data = $tmpData;
                        }
 
-                       $data = HashWrapper::wrap($data, 'md5', function ($hash) {
-                               $this->header('X-Hash-MD5: ' . $hash);
-                       });
-                       $data = HashWrapper::wrap($data, 'sha1', function ($hash) {
-                               $this->header('X-Hash-SHA1: ' . $hash);
-                       });
-                       $data = HashWrapper::wrap($data, 'sha256', function ($hash) {
-                               $this->header('X-Hash-SHA256: ' . $hash);
-                       });
+                       if ($this->request->getHeader('X-HASH') !== '') {
+                               $hash = $this->request->getHeader('X-HASH');
+                               if ($hash === 'all' || $hash === 'md5') {
+                                       $data = HashWrapper::wrap($data, 'md5', function ($hash) {
+                                               $this->header('X-Hash-MD5: ' . $hash);
+                                       });
+                               }
+
+                               if ($hash === 'all' || $hash === 'sha1') {
+                                       $data = HashWrapper::wrap($data, 'sha1', function ($hash) {
+                                               $this->header('X-Hash-SHA1: ' . $hash);
+                                       });
+                               }
+
+                               if ($hash === 'all' || $hash === 'sha256') {
+                                       $data = HashWrapper::wrap($data, 'sha256', function ($hash) {
+                                               $this->header('X-Hash-SHA256: ' . $hash);
+                                       });
+                               }
+                       }
 
                        if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) {
                                $isEOF = false;