diff options
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/File.php')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/File.php | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 2c108819e9f..a7a2470b4f6 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -41,6 +41,7 @@ namespace OCA\DAV\Connector\Sabre; use Icewind\Streams\CallbackWrapper; use OC\AppFramework\Http\Request; use OC\Files\Filesystem; +use OC\Files\Stream\HashWrapper; use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\EntityTooLarge; use OCA\DAV\Connector\Sabre\Exception\FileLocked; @@ -173,16 +174,26 @@ class File extends Node implements IFile { $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE); } - if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) { - if (!is_resource($data)) { - $tmpData = fopen('php://temp', 'r+'); - if ($data !== null) { - fwrite($tmpData, $data); - rewind($tmpData); - } - $data = $tmpData; + if (!is_resource($data)) { + $tmpData = fopen('php://temp', 'r+'); + if ($data !== null) { + fwrite($tmpData, $data); + rewind($tmpData); } + $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 ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) { $isEOF = false; $wrappedData = CallbackWrapper::wrap($data, null, null, null, null, function ($stream) use (&$isEOF) { $isEOF = feof($stream); |