FileFullyUploaded: path.

dev
Karchnu 2020-06-14 18:16:01 +02:00
parent de53bf59a2
commit ad5fbf424e
2 changed files with 8 additions and 4 deletions

View File

@ -65,9 +65,9 @@ class FileStorage::Errors
JSONIPC.request FileFullyUploaded, 206 do JSONIPC.request FileFullyUploaded, 206 do
property mid : String property mid : String
property reason = "file already uploaded fully" property reason = "file already uploaded fully"
property filedigest : String property path : String
def initialize(@mid, @filedigest) def initialize(@mid, @path)
end end
end end
FileStorage.errors << FileFullyUploaded FileStorage.errors << FileFullyUploaded

View File

@ -100,6 +100,7 @@ class FileStorage::Storage
chunk_size = FileStorage.message_buffer_size chunk_size = FileStorage.message_buffer_size
chunk_number = message.chunk.n chunk_number = message.chunk.n
data = Base64.decode message.data data = Base64.decode message.data
path = get_path file_digest
# Verify that the chunk sent was really missing. # Verify that the chunk sent was really missing.
if transfer_info.chunks.select do |v| v == chunk_number end.size == 1 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 return FileStorage::Errors::ChunkAlreadyUploaded.new mid, file_digest, next_chunk
rescue e : IndexError rescue e : IndexError
# In case the file was completely uploaded already. # 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 rescue e
puts "error during transfer_info.chunks.sort.first" puts "error during transfer_info.chunks.sort.first"
raise e raise e
@ -198,7 +199,10 @@ class FileStorage::Storage
return FileStorage::Errors::FileExists.new mid, path, next_chunk return FileStorage::Errors::FileExists.new mid, path, next_chunk
rescue e : IndexError rescue e : IndexError
# In case the file was completely uploaded already. # 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
end end