Skip to content

Commit

Permalink
when reading an empty file getting EOF is not an error
Browse files Browse the repository at this point in the history
will allow uploading empty files via bulk upload

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
  • Loading branch information
mgallien committed Jul 24, 2023
1 parent f88cce7 commit f79caf2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/dav/lib/BulkUpload/MultipartRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,17 @@ private function readPartContent(int $length, string $md5): string {
throw new BadRequest("Computed md5 hash is incorrect.");
}

$content = stream_get_line($this->stream, $length);
if ($length === 0) {
$content = '';
} else {
$content = stream_get_line($this->stream, $length);
}

if ($content === false) {
throw new Exception("Fail to read part's content.");
}

if (feof($this->stream)) {
if ($length !== 0 && feof($this->stream)) {
throw new Exception("Unexpected EOF while reading stream.");
}

Expand Down

0 comments on commit f79caf2

Please sign in to comment.