From f4e69eb109574e0a8a6f05a374f6b033c6756079 Mon Sep 17 00:00:00 2001 From: Bulat-Ziganshin Date: Thu, 25 Aug 2022 14:50:52 +0300 Subject: [PATCH] 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. --- codex/rest/api.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codex/rest/api.nim b/codex/rest/api.nim index 6b374de8..0efc87d1 100644 --- a/codex/rest/api.nim +++ b/codex/rest/api.nim @@ -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)