2020-09-17 17:09:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# PagesDeployment stores a zip archive containing GitLab Pages web-site
|
|
|
|
class PagesDeployment < ApplicationRecord
|
2020-09-24 14:09:51 -04:00
|
|
|
include FileStoreMounter
|
|
|
|
|
2020-09-17 17:09:39 -04:00
|
|
|
belongs_to :project, optional: false
|
|
|
|
belongs_to :ci_build, class_name: 'Ci::Build', optional: true
|
|
|
|
|
2020-10-29 11:09:12 -04:00
|
|
|
scope :older_than, -> (id) { where('id < ?', id) }
|
|
|
|
|
2020-09-17 17:09:39 -04:00
|
|
|
validates :file, presence: true
|
|
|
|
validates :file_store, presence: true, inclusion: { in: ObjectStorage::SUPPORTED_STORES }
|
|
|
|
validates :size, presence: true, numericality: { greater_than: 0, only_integer: true }
|
2020-10-22 11:08:25 -04:00
|
|
|
validates :file_count, presence: true, numericality: { greater_than_or_equal_to: 0, only_integer: true }
|
|
|
|
validates :file_sha256, presence: true
|
2020-09-24 14:09:51 -04:00
|
|
|
|
2020-10-12 14:08:31 -04:00
|
|
|
before_validation :set_size, if: :file_changed?
|
|
|
|
|
|
|
|
default_value_for(:file_store) { ::Pages::DeploymentUploader.default_store }
|
|
|
|
|
2020-09-24 14:09:51 -04:00
|
|
|
mount_file_store_uploader ::Pages::DeploymentUploader
|
2020-10-12 14:08:31 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_size
|
|
|
|
self.size = file.size
|
|
|
|
end
|
2020-09-17 17:09:39 -04:00
|
|
|
end
|