A few log message changes.

This commit is contained in:
Karchnu 2020-10-21 23:24:53 +02:00
parent bfa43f2667
commit edc7cdb6f3
2 changed files with 4 additions and 8 deletions

View File

@ -85,7 +85,6 @@ class FileStorage::Client < IPC::Client
def get_chunks(dl_response : FileStorage::Response::Download, path : String = ".") def get_chunks(dl_response : FileStorage::Response::Download, path : String = ".")
file_path = "#{path}/#{dl_response.file_info.name}" file_path = "#{path}/#{dl_response.file_info.name}"
Baguette::Log.debug "Getting #{file_path}"
digest = dl_response.file_info.digest digest = dl_response.file_info.digest
buffer_size = FileStorage.message_buffer_size buffer_size = FileStorage.message_buffer_size
@ -94,12 +93,10 @@ class FileStorage::Client < IPC::Client
size = 0 size = 0
while counter < dl_response.file_info.nb_chunks while counter < dl_response.file_info.nb_chunks
Baguette::Log.debug "Getting #{file_path}: chunk #{counter+1}/#{dl_response.file_info.nb_chunks}" Baguette::Log.debug "getting #{file_path}: chunk #{counter+1}/#{dl_response.file_info.nb_chunks}"
get_chunk_message = FileStorage::Request::GetChunk.new digest, counter get_chunk_message = FileStorage::Request::GetChunk.new digest, counter
send_now @server_fd.not_nil!, get_chunk_message send_now @server_fd.not_nil!, get_chunk_message
response = parse_message [ FileStorage::Response::GetChunk ], read response = parse_message [ FileStorage::Response::GetChunk ], read
# TODO: write the file
pp! response
case response case response
when FileStorage::Response::GetChunk when FileStorage::Response::GetChunk
@ -120,7 +117,8 @@ class FileStorage::Client < IPC::Client
data : Bytes data : Bytes
) )
pp! file_path, chunk_size, offset, data.size # pp! file_path, chunk_size, offset, data.size
Baguette::Log.debug "writing on #{file_path}"
# Create the file if non existant. # Create the file if non existant.
File.open(file_path, "a+") do |file| File.open(file_path, "a+") do |file|

View File

@ -126,8 +126,6 @@ def put(client : FileStorage::Client)
end end
def get(client : FileStorage::Client) def get(client : FileStorage::Client)
Baguette::Log.warning "get command not complete, yet"
files = Context.args files = Context.args
files.each do |filedigest| files.each do |filedigest|
response = client.download filedigest response = client.download filedigest
@ -136,7 +134,7 @@ def get(client : FileStorage::Client)
Baguette::Log.info "downloading file #{filedigest} with #{response.file_info.nb_chunks} chunks" Baguette::Log.info "downloading file #{filedigest} with #{response.file_info.nb_chunks} chunks"
client.get_chunks response, Context.path client.get_chunks response, Context.path
else else
Baguette::Log.error ">> #{response.class.name}" Baguette::Log.error "#{response.class.name}"
next next
end end
end end