Skip to content

Commit eb196b0

Browse files
committed
when reading an empty file getting EOF is not an error
will allow uploading empty files via bulk upload Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
1 parent 77f2497 commit eb196b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/dav/lib/BulkUpload/MultipartRequestParser.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,17 @@ private function readPartContent(int $length, string $md5): string {
211211
throw new BadRequest("Computed md5 hash is incorrect.");
212212
}
213213

214-
$content = stream_get_line($this->stream, $length);
214+
if ($length === 0) {
215+
$content = '';
216+
} else {
217+
$content = stream_get_line($this->stream, $length);
218+
}
215219

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

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

0 commit comments

Comments
 (0)