debian-mirror-gitlab/lib/gitlab/checks/lfs_check.rb

28 lines
955 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Gitlab
module Checks
2021-09-04 01:27:46 +05:30
class LfsCheck < BaseBulkChecker
2019-12-04 20:38:33 +05:30
LOG_MESSAGE = 'Scanning repository for blobs stored in LFS and verifying their files have been uploaded to GitLab...'
ERROR_MESSAGE = 'LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".'
2019-02-15 15:39:39 +05:30
def validate!
2021-09-30 23:02:18 +05:30
# This feature flag is used for disabling integrity check on some envs
2020-10-24 23:57:45 +05:30
# because these costy calculations may cause performance issues
2022-07-16 23:28:13 +05:30
return unless Feature.enabled?(:lfs_check, project)
2020-10-24 23:57:45 +05:30
2019-02-15 15:39:39 +05:30
return unless project.lfs_enabled?
logger.log_timed(LOG_MESSAGE) do
2021-09-04 01:27:46 +05:30
newrevs = changes.map { |change| change[:newrev] }
lfs_check = Checks::LfsIntegrity.new(project, newrevs, logger.time_left)
2019-02-15 15:39:39 +05:30
if lfs_check.objects_missing?
2020-04-08 14:13:33 +05:30
raise GitAccess::ForbiddenError, ERROR_MESSAGE
2019-02-15 15:39:39 +05:30
end
end
end
end
end
end