Better chunk print, bugfix.
parent
ad5fbf424e
commit
11f58165ca
|
@ -27,6 +27,8 @@ class FileStorage::Request
|
||||||
|
|
||||||
user_data = filestoraged.get_user_data user.uid
|
user_data = filestoraged.get_user_data user.uid
|
||||||
|
|
||||||
|
puts "PutChunk request: #{@mid}, file #{@filedigest}, chunk: n=#{@chunk.n}, on=#{@chunk.on}, digest={@chunk.digest}"
|
||||||
|
|
||||||
filestoraged.storage.write_chunk self, user_data
|
filestoraged.storage.write_chunk self, user_data
|
||||||
rescue e
|
rescue e
|
||||||
return Errors::GenericError.new @mid, e.to_s
|
return Errors::GenericError.new @mid, e.to_s
|
||||||
|
|
|
@ -108,9 +108,11 @@ class FileStorage::Storage
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
# Send the next remaining chunk to upload.
|
# Send the next remaining chunk to upload.
|
||||||
next_chunk = transfer_info.chunks.sort.first
|
chunks = transfer_info.chunks
|
||||||
return FileStorage::Errors::ChunkAlreadyUploaded.new mid, file_digest, next_chunk
|
if chunks.size != 0
|
||||||
rescue e : IndexError
|
next_chunk = transfer_info.chunks.sort.first
|
||||||
|
return FileStorage::Errors::ChunkAlreadyUploaded.new mid, file_digest, next_chunk
|
||||||
|
end
|
||||||
# In case the file was completely uploaded already.
|
# In case the file was completely uploaded already.
|
||||||
return FileStorage::Errors::FileFullyUploaded.new mid, path
|
return FileStorage::Errors::FileFullyUploaded.new mid, path
|
||||||
rescue e
|
rescue e
|
||||||
|
@ -188,16 +190,21 @@ class FileStorage::Storage
|
||||||
# First: check if the file already exists.
|
# First: check if the file already exists.
|
||||||
transfer_info = @db_by_filedigest.get? file_digest
|
transfer_info = @db_by_filedigest.get? file_digest
|
||||||
if transfer_info.nil?
|
if transfer_info.nil?
|
||||||
|
puts "new file: #{file_digest}"
|
||||||
|
|
||||||
# In case file informations aren't already registered
|
# In case file informations aren't already registered
|
||||||
# which is normal at this point.
|
# which is normal at this point.
|
||||||
@db << TransferInfo.new user.uid, request.file
|
@db << TransferInfo.new user.uid, request.file
|
||||||
else
|
else
|
||||||
|
puts "file already upload (at least partially): #{file_digest}"
|
||||||
# File information already exists, request may be duplicated,
|
# File information already exists, request may be duplicated,
|
||||||
# in this case: ignore the upload request.
|
# in this case: ignore the upload request.
|
||||||
begin
|
begin
|
||||||
next_chunk = transfer_info.chunks.sort.first
|
chunks = transfer_info.chunks
|
||||||
return FileStorage::Errors::FileExists.new mid, path, next_chunk
|
if chunks.size != 0
|
||||||
rescue e : IndexError
|
next_chunk = chunks.sort.first
|
||||||
|
return FileStorage::Errors::FileExists.new mid, path, next_chunk
|
||||||
|
end
|
||||||
# In case the file was completely uploaded already.
|
# In case the file was completely uploaded already.
|
||||||
return FileStorage::Errors::FileFullyUploaded.new mid, path
|
return FileStorage::Errors::FileFullyUploaded.new mid, path
|
||||||
rescue e
|
rescue e
|
||||||
|
|
Loading…
Reference in New Issue