diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /app/models/ci/secure_file.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/models/ci/secure_file.rb')
-rw-r--r-- | app/models/ci/secure_file.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/ci/secure_file.rb b/app/models/ci/secure_file.rb index 18f0093ea41..6a26a5341aa 100644 --- a/app/models/ci/secure_file.rb +++ b/app/models/ci/secure_file.rb @@ -15,7 +15,9 @@ module Ci validates :file, presence: true, file_size: { maximum: FILE_SIZE_LIMIT } validates :checksum, :file_store, :name, :permissions, :project_id, presence: true + validates :name, uniqueness: { scope: :project } + after_initialize :generate_key_data before_validation :assign_checksum enum permissions: { read_only: 0, read_write: 1, execute: 2 } @@ -33,5 +35,11 @@ module Ci def assign_checksum self.checksum = file.checksum if file.present? && file_changed? end + + def generate_key_data + return if key_data.present? + + self.key_data = SecureRandom.hex(64) + end end end |