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
end
def get_chunk
return '' unless size > 0
return '' if size <= 0 || eof?
unless in_range?
chunk_store.open(job_id, chunk_index, params_for_store) do |store|
......@@ -233,8 +233,8 @@ module Gitlab
(size / buffer_size.to_f).ceil
end
def last_range
((size / buffer_size) * buffer_size..size)
def last_chunk?
((size / buffer_size) * buffer_size..size).include?(tell)
end
def chunk_store
......
......@@ -25,6 +25,7 @@ module Gitlab
def truncate(offset)
if offset == 0
delete
@size = @tell = 0
elsif offset == size
# no-op
else
......@@ -45,7 +46,7 @@ module Gitlab
end
def chunk_store
if last_range.include?(tell)
if last_chunk?
ChunkedFile::ChunkStore::Redis
else
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