blob: 3e84bc4ebc963959c779caea65c7509be3617dd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# frozen_string_literal: true
module ObjectStorage
class PendingDirectUpload
KEY = 'pending_direct_uploads'
def self.prepare(location_identifier, path)
::Gitlab::Redis::SharedState.with do |redis|
# We need to store the location_identifier together with the timestamp to properly delete
# this object if ever this upload gets stale. The location identifier will be used
# by the clean up worker to properly generate the storage options through ObjectStorage::Config.for_location
redis.hset(KEY, key(location_identifier, path), Time.current.utc.to_i)
end
end
def self.exists?(location_identifier, path)
::Gitlab::Redis::SharedState.with do |redis|
redis.hexists(KEY, key(location_identifier, path))
end
end
def self.complete(location_identifier, path)
::Gitlab::Redis::SharedState.with do |redis|
redis.hdel(KEY, key(location_identifier, path))
end
end
def self.key(location_identifier, path)
[location_identifier, path].join(':')
end
end
end
|