Commit ebf69adc authored by Shinya Maeda's avatar Shinya Maeda

Optimize chunk_store selector

parent 3a0f9003
......@@ -236,7 +236,7 @@ module Gitlab
end
def last_chunk?
chunks_count == 0 || chunk_index == (chunks_count - 1)
(chunk_start...chunk_end).include?(tell)
end
def chunk_store
......
......@@ -18,7 +18,7 @@ module Gitlab
def stash_to_database(store)
# Once data is filled into redis, move the data to database
if store.filled? &&
if store.filled?
ChunkStore::Database.open(job_id, chunk_index, params_for_store) do |to_store|
to_store.write!(store.get)
store.delete!
......@@ -28,7 +28,7 @@ module Gitlab
# Efficient process than iterating each
def truncate(offset)
if truncate == 0
if offset == 0
delete
elsif offset == size
# no-op
......@@ -54,7 +54,7 @@ module Gitlab
end
def chunk_store
if last_chunk?
if last_chunk? || eof?
ChunkStore::Redis
else
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