Skip to content

Commit

Permalink
Merge pull request #20927 from owncloud/handle-return-code-on-webdav-put
Browse files Browse the repository at this point in the history
Handle return code of streamCopy in WebDAV put
  • Loading branch information
DeepDiver1975 committed Jan 15, 2016
2 parents 6824704 + 43f5d8a commit 6a7be4d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/dav/lib/connector/sabre/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,17 @@ 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');
}
list($count,) = \OC_Helper::streamCopy($data, $target);
list($count, $result) = \OC_Helper::streamCopy($data, $target);
fclose($target);

if($result === false) {
$expected = -1;
if (isset($_SERVER['CONTENT_LENGTH'])) {
$expected = $_SERVER['CONTENT_LENGTH'];
}
throw new Exception('Error while copying file to target location (copied bytes: ' . $count . ', expected filesize: '. $expected .' )');
}

// if content length is sent by client:
// double check if the file was fully received
// compare expected and actual size
Expand Down

0 comments on commit 6a7be4d

Please sign in to comment.