2020-12-02 06:09:50 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DependencyProxy::Manifest < ApplicationRecord
|
|
|
|
include FileStoreMounter
|
2021-09-29 18:12:42 +00:00
|
|
|
include TtlExpirable
|
2022-01-18 15:14:54 +00:00
|
|
|
include Packages::Destructible
|
2021-09-29 18:12:42 +00:00
|
|
|
include EachBatch
|
2022-02-17 18:19:40 +00:00
|
|
|
include UpdateNamespaceStatistics
|
2020-12-02 06:09:50 +00:00
|
|
|
|
|
|
|
belongs_to :group
|
2022-02-17 18:19:40 +00:00
|
|
|
alias_attribute :namespace, :group
|
2020-12-02 06:09:50 +00:00
|
|
|
|
2021-11-04 09:12:56 +00:00
|
|
|
MAX_FILE_SIZE = 10.megabytes.freeze
|
2021-11-09 15:12:42 +00:00
|
|
|
DIGEST_HEADER = 'Docker-Content-Digest'
|
2021-11-04 09:12:56 +00:00
|
|
|
|
2020-12-02 06:09:50 +00:00
|
|
|
validates :group, presence: true
|
|
|
|
validates :file, presence: true
|
|
|
|
validates :file_name, presence: true
|
|
|
|
validates :digest, presence: true
|
|
|
|
|
2021-11-09 15:12:42 +00:00
|
|
|
scope :order_id_desc, -> { reorder(id: :desc) }
|
2022-02-09 03:17:22 +00:00
|
|
|
scope :with_files_stored_locally, -> { where(file_store: ::DependencyProxy::FileUploader::Store::LOCAL) }
|
2021-11-09 15:12:42 +00:00
|
|
|
|
2020-12-02 06:09:50 +00:00
|
|
|
mount_file_store_uploader DependencyProxy::FileUploader
|
2022-02-17 18:19:40 +00:00
|
|
|
update_namespace_statistics namespace_statistics_name: :dependency_proxy_size
|
2020-12-11 00:09:41 +00:00
|
|
|
|
2021-11-04 09:12:56 +00:00
|
|
|
def self.find_by_file_name_or_digest(file_name:, digest:)
|
|
|
|
find_by(file_name: file_name) || find_by(digest: digest)
|
2021-02-22 18:10:55 +00:00
|
|
|
end
|
2020-12-02 06:09:50 +00:00
|
|
|
end
|
2022-02-09 03:17:22 +00:00
|
|
|
|
|
|
|
DependencyProxy::Manifest.prepend_mod_with('DependencyProxy::Manifest')
|