Optimize chunk_store selector
This commit is contained in:
parent
3a0f900318
commit
ebf69adc21
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue