From b72d54f19d6139b7a69ad291a69a7ca4e1bc9403 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Wed, 20 May 2020 09:49:16 +0200 Subject: [PATCH] Add file_digest in Response::Transfer. --- src/common/requests/transfer.cr | 3 ++- src/server/storage.cr | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/requests/transfer.cr b/src/common/requests/transfer.cr index aee7669..dcc9d20 100644 --- a/src/common/requests/transfer.cr +++ b/src/common/requests/transfer.cr @@ -56,8 +56,9 @@ end class FileStorage::Response JSONIPC.request Transfer, 40 do property mid : String + property file_digest : String property n : Int32 # chunk number - def initialize(@mid, @n) + def initialize(@mid, @file_digest, @n) end end end diff --git a/src/server/storage.cr b/src/server/storage.cr index 9e8e448..9b83534 100644 --- a/src/server/storage.cr +++ b/src/server/storage.cr @@ -82,7 +82,8 @@ class FileStorage::Storage # TODO: verify the digest, if no more chunks. - FileStorage::Response::Transfer.new mid, chunk_number + digest = transfer_info.file_info.digest + FileStorage::Response::Transfer.new mid, digest, chunk_number rescue e puts "Error handling transfer: #{e.message}" FileStorage::Response::Error.new mid.not_nil!, "Unexpected error: #{e.message}"