From 2cd758317adc0755e7741e78685e9f103c21156b Mon Sep 17 00:00:00 2001 From: Karchnu Date: Thu, 22 Oct 2020 02:08:12 +0200 Subject: [PATCH] Client fix: don't try to put files when too big. --- src/client/main.cr | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/main.cr b/src/client/main.cr index c0035be..577231b 100644 --- a/src/client/main.cr +++ b/src/client/main.cr @@ -112,13 +112,17 @@ def put(client : FileStorage::Client) end files.each do |file| + file_info = File.open(file) do |f| + FileStorage::FileInfo.new f + end response = client.upload file - if response.is_a?(FileStorage::Errors::FileFullyUploaded) - file_info = File.open(file) do |f| - FileStorage::FileInfo.new f - end + case response + when FileStorage::Errors::FileFullyUploaded Baguette::Log.warning "file #{file} already uploaded, digest: #{file_info.digest}" next + when FileStorage::Errors::FileTooBig + Baguette::Log.warning "file #{file} too big, accepting up to #{response.limit} bytes" + next end Baguette::Log.info "transfering: #{file}" client.transfer file