Skip to content

Commit f537411

Browse files
committed
fix handling of 0 size files
Resolves this error: {"time":"2025-06-10T16:20:12.995795959-07:00","level":"INFO","msg":"http: panic serving 127.0.0.1:46858: n must be positive number\ngoroutine 20 [running]:\nnet/http.(*conn).serve.func1()\n\t/home/jhoblitt/sdk/go1.24.3/src/net/http/server.go:1947 +0xbe\npanic ...
1 parent 113f7e4 commit f537411

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

upload/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ func (h *S3ndHandler) parseRequest(task *UploadTask, r *http.Request) error {
345345
return errors.Wrapf(err, "could not stat file %v", *task.File)
346346
}
347347
task.SizeBytes = fStat.Size()
348-
task.UploadParts = divCeil(task.SizeBytes, h.conf.UploadPartsize.Value())
348+
// if the file is empty, we still need to upload it, so set the part size to 1
349+
task.UploadParts = max(divCeil(task.SizeBytes, h.conf.UploadPartsize.Value()), 1)
349350

350351
return nil
351352
}

0 commit comments

Comments
 (0)