summaryrefslogtreecommitdiff
path: root/app/models/ci/build_trace_chunks/fog.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/build_trace_chunks/fog.rb')
-rw-r--r--app/models/ci/build_trace_chunks/fog.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/models/ci/build_trace_chunks/fog.rb b/app/models/ci/build_trace_chunks/fog.rb
index a849bd08427..b1e9fd1faeb 100644
--- a/app/models/ci/build_trace_chunks/fog.rb
+++ b/app/models/ci/build_trace_chunks/fog.rb
@@ -9,10 +9,26 @@ module Ci
def data(model)
connection.get_object(bucket_name, key(model))[:body]
+ rescue Excon::Error::NotFound
+ # If the object does not exist in the object storage, this method returns nil.
end
- def set_data(model, data)
- connection.put_object(bucket_name, key(model), data)
+ def set_data(model, new_data)
+ connection.put_object(bucket_name, key(model), 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
+
+ set_data(model, new_data)
+ new_data.bytesize
+ end
+
+ def size(model)
+ data(model).to_s.bytesize
end
def delete_data(model)