Send the number of the next chunk to be uploaded.

dev
Karchnu 2020-06-08 20:03:17 +02:00
parent 60b9d9fa01
commit 854f383172
2 changed files with 5 additions and 4 deletions

View File

@ -20,9 +20,9 @@ class FileStorage::Errors
property mid : String
property reason = "Chunk already present"
property filedigest : String
property chunk : Chunk
property next_chunk : Int32
def initialize(@mid, @filedigest, @chunk)
def initialize(@mid, @filedigest, @next_chunk)
end
end
FileStorage.errors << ChunkAlreadyUploaded

View File

@ -105,8 +105,9 @@ class FileStorage::Storage
if transfer_info.chunks.select do |v| v == chunk_number end.size == 1
write_a_chunk file_digest, chunk_size, chunk_number, data
else
# TODO: send the remaining chunks to upload.
raise "non existent chunk or already uploaded"
# Send the next remaining chunk to upload.
next_chunk = transfer_info.chunks.sort.first
return FileStorage::Errors::ChunkAlreadyUploaded.new mid, file_digest, next_chunk
end
remove_chunk_from_db transfer_info, chunk_number