diff options
Diffstat (limited to 'lib/gitlab/verify/batch_verifier.rb')
-rw-r--r-- | lib/gitlab/verify/batch_verifier.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/gitlab/verify/batch_verifier.rb b/lib/gitlab/verify/batch_verifier.rb index 1ef369a4b67..fd01602c256 100644 --- a/lib/gitlab/verify/batch_verifier.rb +++ b/lib/gitlab/verify/batch_verifier.rb @@ -34,15 +34,28 @@ module Gitlab end def verify(object) + if local?(object) + verify_local(object) + else + verify_remote(object) + end + + nil + rescue => err + [object, err] + end + + def verify_local(object) expected = expected_checksum(object) actual = actual_checksum(object) raise 'Checksum missing' unless expected.present? raise 'Checksum mismatch' unless expected == actual + end - nil - rescue => err - [object, err] + # We don't calculate checksum for remote objects, so just check existence + def verify_remote(object) + raise 'Remote object does not exist' unless object.build_uploader.exists? end # This should return an ActiveRecord::Relation suitable for calling #in_batches on @@ -50,6 +63,11 @@ module Gitlab raise NotImplementedError.new end + # Should return true if the object is stored locally + def local?(_object) + raise NotImplementedError.new + end + # The checksum we expect the object to have def expected_checksum(_object) raise NotImplementedError.new |