debian-mirror-gitlab/app/models/ci/build_trace_chunks/database.rb

44 lines
873 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module Ci
module BuildTraceChunks
class Database
def keys(relation)
[]
end
def delete_keys(keys)
# no-op
end
def data(model)
model.raw_data
2021-01-03 14:25:43 +05:30
rescue ActiveModel::MissingAttributeError
model.reset.raw_data
2018-11-08 19:23:39 +05:30
end
2020-10-24 23:57:45 +05:30
def set_data(model, new_data)
model.raw_data = new_data
end
def append_data(model, new_data, offset)
if offset > 0
truncated_data = data(model).to_s.byteslice(0, offset)
new_data = truncated_data + new_data
end
2020-11-24 15:15:51 +05:30
set_data(model, new_data)
2020-10-24 23:57:45 +05:30
model.raw_data.to_s.bytesize
end
def size(model)
data(model).to_s.bytesize
2018-11-08 19:23:39 +05:30
end
def delete_data(model)
model.update_columns(raw_data: nil) unless model.raw_data.nil?
end
end
end
end