2020-11-13 21:09:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DependencyProxy::Blob < 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
|
2020-11-13 21:09:31 +00:00
|
|
|
|
|
|
|
belongs_to :group
|
|
|
|
|
2021-11-04 09:12:56 +00:00
|
|
|
MAX_FILE_SIZE = 5.gigabytes.freeze
|
|
|
|
|
2020-11-13 21:09:31 +00:00
|
|
|
validates :group, presence: true
|
|
|
|
validates :file, presence: true
|
|
|
|
validates :file_name, presence: true
|
|
|
|
|
2022-02-09 03:17:22 +00:00
|
|
|
scope :with_files_stored_locally, -> { where(file_store: ::DependencyProxy::FileUploader::Store::LOCAL) }
|
|
|
|
|
2020-11-13 21:09:31 +00:00
|
|
|
mount_file_store_uploader DependencyProxy::FileUploader
|
|
|
|
|
|
|
|
def self.total_size
|
|
|
|
sum(:size)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.find_or_build(file_name)
|
|
|
|
find_or_initialize_by(file_name: file_name)
|
|
|
|
end
|
|
|
|
end
|
2022-02-09 03:17:22 +00:00
|
|
|
|
|
|
|
DependencyProxy::Blob.prepend_mod_with('DependencyProxy::Blob')
|