Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fog.rb « uploads « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b44e273e9ab07887b2a244de657374a9e79ba58f (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
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

module Uploads
  class Fog < Base
    include ::Gitlab::Utils::StrongMemoize

    def available?
      object_store.enabled
    end

    def keys(relation)
      return [] unless available?

      relation.pluck(:path)
    end

    def delete_keys(keys)
      keys.each do |key|
        connection.delete_object(bucket_name, key)
      end
    end

    private

    def object_store
      Gitlab.config.uploads.object_store
    end

    def bucket_name
      return unless available?

      object_store.remote_directory
    end

    def connection
      return unless available?

      strong_memoize(:connection) do
        ::Fog::Storage.new(object_store.connection.to_hash.deep_symbolize_keys)
      end
    end
  end
end