Commit cb3a0e33 authored by Shinya Maeda's avatar Shinya Maeda

Fix bug; truncate did not reset size and tell

parent 9766af36
...@@ -152,7 +152,7 @@ module Gitlab ...@@ -152,7 +152,7 @@ module Gitlab
end end
def get_chunk def get_chunk
return '' unless size > 0 return '' if size <= 0 || eof?
unless in_range? unless in_range?
chunk_store.open(job_id, chunk_index, params_for_store) do |store| chunk_store.open(job_id, chunk_index, params_for_store) do |store|
...@@ -233,8 +233,8 @@ module Gitlab ...@@ -233,8 +233,8 @@ module Gitlab
(size / buffer_size.to_f).ceil (size / buffer_size.to_f).ceil
end end
def last_range def last_chunk?
((size / buffer_size) * buffer_size..size) ((size / buffer_size) * buffer_size..size).include?(tell)
end end
def chunk_store def chunk_store
......
...@@ -25,6 +25,7 @@ module Gitlab ...@@ -25,6 +25,7 @@ module Gitlab
def truncate(offset) def truncate(offset)
if offset == 0 if offset == 0
delete delete
@size = @tell = 0
elsif offset == size elsif offset == size
# no-op # no-op
else else
...@@ -45,7 +46,7 @@ module Gitlab ...@@ -45,7 +46,7 @@ module Gitlab
end end
def chunk_store def chunk_store
if last_range.include?(tell) if last_chunk?
ChunkedFile::ChunkStore::Redis ChunkedFile::ChunkStore::Redis
else else
ChunkedFile::ChunkStore::Database ChunkedFile::ChunkStore::Database
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment