Skip to content

Commit

Permalink
Make written byte counter variable name more obvious
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Aug 5, 2021
1 parent 259f8c4 commit 720fc91
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand All @@ -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 . ' )');
}
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 720fc91

Please sign in to comment.