From 52409bdfec007973bfc5272db1354be0aacb7a84 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Fri, 29 May 2020 18:36:51 +0200 Subject: [PATCH] Fix the verification on the uploaded chunks. --- src/server/storage.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server/storage.cr b/src/server/storage.cr index 9b83534..950e39b 100644 --- a/src/server/storage.cr +++ b/src/server/storage.cr @@ -71,10 +71,11 @@ class FileStorage::Storage data = Base64.decode message.data - # TODO: verify that the chunk sent was really missing. - if transfer_info.chunks.select(chunk_number).size > 0 + # Verify that the chunk sent was really missing. + if transfer_info.chunks.select do |v| v == chunk_number end.size == 1 write_a_chunk user.uid.to_s, transfer_info.file_info, chunk_number, data else + # TODO: send the remaining chunks to upload. raise "non existent chunk or already uploaded" end