Deal with absent or incorrect ?chunk value

Pass blockSize to node.store only when correct REST ?chunk value was provided, otherwise node.store will use  its default value.

Also added MaxBlockSize=1 GB, so we have reasonable limit to block sizes provided by users.
This commit is contained in:
Bulat-Ziganshin 2022-08-25 14:50:52 +03:00 committed by benbierens
parent 967f601c2d
commit f4e69eb109
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
1 changed files with 1 additions and 1 deletions

View File

@ -181,7 +181,7 @@ proc initRestApi*(node: CodexNodeRef, conf: CodexConf): RestRouter =
try:
let runUpload =
if blockSize =? chunk.get:
if (chunkOpt =? chunk) and (blockSize =? chunkOpt) and (blockSize <= MaxBlockSize):
node.store(bodyStream, blockSize = blockSize.int)
else:
node.store(bodyStream)