2018-12-04 06:55:49 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Checks
|
|
|
|
class LfsCheck < BaseChecker
|
2019-08-31 15:25:25 -04:00
|
|
|
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".'
|
2018-12-04 06:55:49 -05:00
|
|
|
|
|
|
|
def validate!
|
2020-08-06 11:09:42 -04:00
|
|
|
# This feature flag is used for disabling integrify check on some envs
|
|
|
|
# because these costy calculations may cause performance issues
|
|
|
|
return unless Feature.enabled?(:lfs_check, default_enabled: true)
|
|
|
|
|
2018-12-28 05:44:25 -05:00
|
|
|
return unless project.lfs_enabled?
|
2018-12-04 06:55:49 -05:00
|
|
|
return if skip_lfs_integrity_check
|
|
|
|
|
|
|
|
logger.log_timed(LOG_MESSAGE) do
|
|
|
|
lfs_check = Checks::LfsIntegrity.new(project, newrev, logger.time_left)
|
|
|
|
|
|
|
|
if lfs_check.objects_missing?
|
2020-02-26 13:09:24 -05:00
|
|
|
raise GitAccess::ForbiddenError, ERROR_MESSAGE
|
2018-12-04 06:55:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|