From eb540ed871182fd272a54e2eb3855b9dbd5e73d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 5 Aug 2021 09:32:19 +0200 Subject: [PATCH] fixup! Already pass size difference to the cache updater to avoid full calculation on s3 --- apps/dav/lib/Connector/Sabre/File.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 835110d626e88..04fc84e3361f2 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -202,9 +202,9 @@ public function put($data) { }); $result = true; - $count = -1; + $writtenByteCount = -1; try { - $count = $partStorage->writeStream($internalPartPath, $wrappedData); + $writtenByteCount = $partStorage->writeStream($internalPartPath, $wrappedData); } catch (GenericFileException $e) { $result = false; } @@ -223,7 +223,7 @@ public function put($data) { // because we have no clue about the cause we can only throw back a 500/Internal Server Error throw new Exception('Could not write file contents'); } - [$count, $result] = \OC_Helper::streamCopy($data, $target); + [$writtenByteCount, $result] = \OC_Helper::streamCopy($data, $target); fclose($target); } @@ -233,7 +233,7 @@ public function put($data) { $expected = $_SERVER['CONTENT_LENGTH']; } if ($expected !== "0") { - throw new Exception('Error while copying file to target location (copied bytes: ' . $count . ', expected filesize: ' . $expected . ' )'); + throw new Exception('Error while copying file to target location (copied bytes: ' . $writtenByteCount . ', expected filesize: ' . $expected . ' )'); } } @@ -242,8 +242,8 @@ public function put($data) { // compare expected and actual size if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] === 'PUT') { $expected = (int)$_SERVER['CONTENT_LENGTH']; - if ($count !== $expected) { - throw new BadRequest('Expected filesize of ' . $expected . ' bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) ' . $count . ' bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.'); + if ($writtenByteCount !== $expected) { + throw new BadRequest('Expected filesize of ' . $expected . ' bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) ' . $writtenByteCount . ' bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.'); } } } catch (\Exception $e) { @@ -307,7 +307,7 @@ public function put($data) { } // since we skipped the view we need to scan and emit the hooks ourselves - $storage->getUpdater()->update($internalPath, null, ($count-$previousFileSize)); + $storage->getUpdater()->update($internalPath, null, ($writtenByteCount-$previousFileSize)); try { $this->changeLock(ILockingProvider::LOCK_SHARED);