Send the number of the next chunk to be uploaded.
parent
60b9d9fa01
commit
854f383172
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue