diff options
Diffstat (limited to 'app/models/uploads/fog.rb')
-rw-r--r-- | app/models/uploads/fog.rb | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/app/models/uploads/fog.rb b/app/models/uploads/fog.rb index d2b8eab9f0d..3c31909fb07 100644 --- a/app/models/uploads/fog.rb +++ b/app/models/uploads/fog.rb @@ -2,11 +2,8 @@ module Uploads class Fog < Base - include ::Gitlab::Utils::StrongMemoize - - def available? - object_store.enabled - end + include ::ObjectStorage::FogHelpers + extend ::Gitlab::Utils::Override def keys(relation) return [] unless available? @@ -20,39 +17,9 @@ module Uploads private - def delete_object(key) - return unless available? - - connection.delete_object(bucket_name, object_key(key)) - - # So far, only GoogleCloudStorage raises an exception when the file is not found. - # Other providers support idempotent requests and does not raise an error - # when the file is missing. - rescue ::Google::Apis::ClientError => e - Gitlab::ErrorTracking.log_exception(e) - end - - def object_store - Gitlab.config.uploads.object_store - end - - def bucket_name - object_store.remote_directory - end - - def object_key(key) - # We allow administrators to create "sub buckets" by setting a prefix. - # This makes it possible to deploy GitLab with only one object storage - # bucket. This mirrors the implementation in app/uploaders/object_storage.rb. - File.join([object_store.bucket_prefix, key].compact) - end - - def connection - return unless available? - - strong_memoize(:connection) do - ::Fog::Storage.new(object_store.connection.to_hash.deep_symbolize_keys) - end + override :storage_location_identifier + def storage_location_identifier + :uploads end end end |