diff --git a/src/common/requests/errors.cr b/src/common/requests/errors.cr index f95e3ab..270d1f9 100644 --- a/src/common/requests/errors.cr +++ b/src/common/requests/errors.cr @@ -65,9 +65,9 @@ class FileStorage::Errors JSONIPC.request FileFullyUploaded, 206 do property mid : String property reason = "file already uploaded fully" - property filedigest : String + property path : String - def initialize(@mid, @filedigest) + def initialize(@mid, @path) end end FileStorage.errors << FileFullyUploaded diff --git a/src/server/storage.cr b/src/server/storage.cr index 261b910..9593396 100644 --- a/src/server/storage.cr +++ b/src/server/storage.cr @@ -100,6 +100,7 @@ class FileStorage::Storage chunk_size = FileStorage.message_buffer_size chunk_number = message.chunk.n data = Base64.decode message.data + path = get_path file_digest # Verify that the chunk sent was really missing. if transfer_info.chunks.select do |v| v == chunk_number end.size == 1 @@ -111,7 +112,7 @@ class FileStorage::Storage return FileStorage::Errors::ChunkAlreadyUploaded.new mid, file_digest, next_chunk rescue e : IndexError # In case the file was completely uploaded already. - return FileStorage::Errors::FileFullyUploaded.new mid, file_digest + return FileStorage::Errors::FileFullyUploaded.new mid, path rescue e puts "error during transfer_info.chunks.sort.first" raise e @@ -198,7 +199,10 @@ class FileStorage::Storage return FileStorage::Errors::FileExists.new mid, path, next_chunk rescue e : IndexError # In case the file was completely uploaded already. - return FileStorage::Errors::FileFullyUploaded.new mid, file_digest + return FileStorage::Errors::FileFullyUploaded.new mid, path + rescue e + puts "error at transfer_info.chunks.sort.first in upload" + raise e end end