Skip to content

Commit

Permalink
Make X-HAS-{MD5/SHA256} opt-in
Browse files Browse the repository at this point in the history
This is not always needed and slow down the upload

Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan committed Jun 1, 2022
1 parent cf9660f commit 1b426ed
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,26 @@ public function put($data) {
$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;
Expand Down

0 comments on commit 1b426ed

Please sign in to comment.