diff options
author | Nick Thomas <nick@gitlab.com> | 2018-02-27 19:15:25 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-03-02 14:16:17 +0000 |
commit | 6f945f20b4c3683bc862ebc476bad9331d72784e (patch) | |
tree | 9504637169d3a410e03e9e75f1d72ee6a323187f /lib/tasks/gitlab/uploads.rake | |
parent | 40c61acb6a9ba84928cebcbce8b57630bd439615 (diff) | |
download | gitlab-ce-ee-4862-verify-file-checksums.tar.gz |
Foreground verification of uploads and LFS objectsee-4862-verify-file-checksums
Diffstat (limited to 'lib/tasks/gitlab/uploads.rake')
-rw-r--r-- | lib/tasks/gitlab/uploads.rake | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/lib/tasks/gitlab/uploads.rake b/lib/tasks/gitlab/uploads.rake deleted file mode 100644 index df31567ce64..00000000000 --- a/lib/tasks/gitlab/uploads.rake +++ /dev/null @@ -1,44 +0,0 @@ -namespace :gitlab do - namespace :uploads do - desc 'GitLab | Uploads | Check integrity of uploaded files' - task check: :environment do - puts 'Checking integrity of uploaded files' - - uploads_batches do |batch| - batch.each do |upload| - puts "- Checking file (#{upload.id}): #{upload.absolute_path}".color(:green) - - if upload.exist? - check_checksum(upload) - else - puts " * File does not exist on the file system".color(:red) - end - end - end - - puts 'Done!' - end - - def batch_size - ENV.fetch('BATCH', 200).to_i - end - - def calculate_checksum(absolute_path) - Digest::SHA256.file(absolute_path).hexdigest - end - - def check_checksum(upload) - checksum = calculate_checksum(upload.absolute_path) - - if checksum != upload.checksum - puts " * File checksum (#{checksum}) does not match the one in the database (#{upload.checksum})".color(:red) - end - end - - def uploads_batches(&block) - Upload.all.in_batches(of: batch_size, start: ENV['ID_FROM'], finish: ENV['ID_TO']) do |relation| # rubocop: disable Cop/InBatches - yield relation - end - end - end -end |