summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-06-18 17:56:16 +0900
committerShinya Maeda <shinya@gitlab.com>2018-06-18 17:56:16 +0900
commit494673793d6b4491b2a7843f0614e5bcb3d88a3c (patch)
treea909451fa3453ec5efb7ea6b6110eca67fa524b2 /app/models
parent71e30c011957229dfa4029b9b04e5308ceed4fcd (diff)
downloadgitlab-ce-494673793d6b4491b2a7843f0614e5bcb3d88a3c.tar.gz
Rename persisted? to data_persisted?
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build_trace_chunk.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb
index 179c5830678..59096f54f0b 100644
--- a/app/models/ci/build_trace_chunk.rb
+++ b/app/models/ci/build_trace_chunk.rb
@@ -75,9 +75,7 @@ module Ci
raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0
raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize)
- in_lock(*lock_params) do
- self.reload if self.persisted?
-
+ in_lock(*lock_params) do # Write opetation is atomic
unsafe_set_data!(data.byteslice(0, offset) + new_data)
end
@@ -100,21 +98,19 @@ module Ci
(start_offset...end_offset)
end
- def persisted?
+ def data_persisted?
!redis?
end
- def persist!
- in_lock(*lock_params) do
- self.reload if self.persisted?
-
- unsafe_move_to!(self.class.persist_store)
+ def persist_data!
+ in_lock(*lock_params) do # Write opetation is atomic
+ unsafe_migrate_to!(self.class.persist_store)
end
end
private
- def unsafe_move_to!(new_store)
+ def unsafe_migrate_to!(new_store)
return if data_store == new_store.to_s
return unless size > 0
@@ -143,7 +139,7 @@ module Ci
end
def schedule_to_persist
- return if persisted?
+ return if data_persisted?
Ci::BuildTraceChunkFlushWorker.perform_async(id)
end