Client fix: don't try to put files when too big.

dev
Karchnu 2020-10-22 02:08:12 +02:00
parent 2bea44d119
commit 2cd758317a
1 changed files with 8 additions and 4 deletions

View File

@ -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