Commit 1b5c238a authored by Micaël Bergeron's avatar Micaël Bergeron

remove lint

parent c2faf5ba
require_relative 'helpers.rb' require_relative 'helpers.rb'
include UploadTaskHelpers
namespace :gitlab do namespace :gitlab do
namespace :uploads do namespace :uploads do
desc 'GitLab | Uploads | Check integrity of uploaded files' desc 'GitLab | Uploads | Check integrity of uploaded files'
task check: :environment do task check: :environment do
include UploadTaskHelpers
puts 'Checking integrity of uploaded files' puts 'Checking integrity of uploaded files'
uploads_batches do |batch| uploads_batches do |batch|
batch.each do |upload| batch.each do |upload|
begin begin
puts "- Checking file (#{upload.id}): #{upload.absolute_path}".color(:green) puts "- Checking file (#{upload.id}): #{upload.absolute_path}".color(:green)
if upload.exist? if upload.exist?
check_checksum(upload) check_checksum(upload)
else else
......
...@@ -58,9 +58,10 @@ module UploadTask ...@@ -58,9 +58,10 @@ module UploadTask
def migrate(batch_size, &block) def migrate(batch_size, &block)
each_upload_batch(batch_size) do |batch| each_upload_batch(batch_size) do |batch|
results = build_uploaders(batch) results = build_uploaders(batch).map(&method(:process_uploader))
.map(&method(:process_uploader))
yield results # yield processed batch as [MigrationResult] yield results # yield processed batch as [MigrationResult]
@results.concat(results) @results.concat(results)
end end
end end
...@@ -74,7 +75,7 @@ module UploadTask ...@@ -74,7 +75,7 @@ module UploadTask
.where.not(store: @to_store) .where.not(store: @to_store)
.where(uploader: @uploader_class.to_s, .where(uploader: @uploader_class.to_s,
model_type: @model_class.to_s) model_type: @model_class.to_s)
.in_batches(of: batch_size, &block) .in_batches(of: batch_size, &block) # rubocop: disable Cop/InBatches
end end
def process_uploader(uploader) def process_uploader(uploader)
......
...@@ -5,7 +5,7 @@ describe 'gitlab:uploads rake tasks' do ...@@ -5,7 +5,7 @@ describe 'gitlab:uploads rake tasks' do
let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) } let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) }
before do before do
Rake.application.rake_require 'tasks/gitlab/uploads' Rake.application.rake_require 'tasks/gitlab/uploads/check'
end end
it 'outputs the integrity check for each uploaded file' do it 'outputs the integrity check for each uploaded file' do
...@@ -33,7 +33,7 @@ describe 'gitlab:uploads rake tasks' do ...@@ -33,7 +33,7 @@ describe 'gitlab:uploads rake tasks' do
let(:batch_size) { 3 } let(:batch_size) { 3 }
before do before do
ENV['BATCH'] = batch_size.to_s stub_env('BATCH', batch_size.to_s)
stub_uploads_object_storage(uploader_class) stub_uploads_object_storage(uploader_class)
Rake.application.rake_require 'tasks/gitlab/uploads/migrate' Rake.application.rake_require 'tasks/gitlab/uploads/migrate'
end end
...@@ -50,15 +50,15 @@ describe 'gitlab:uploads rake tasks' do ...@@ -50,15 +50,15 @@ describe 'gitlab:uploads rake tasks' do
batch_count = [batch_size, total].min batch_count = [batch_size, total].min
expect { run }.to output(%r{Migrated #{batch_count}/#{batch_count} files}).to_stdout expect { run }.to output(%r{Migrated #{batch_count}/#{batch_count} files}).to_stdout
end if success > 0 end if success > 0 # rubocop:disable Style/MultilineIfModifier
it 'outputs the results for the task' do it 'outputs the results for the task' do
expect { run }.to output(%r{Migrated #{success}/#{total} files}).to_stdout expect { run }.to output(%r{Migrated #{success}/#{total} files}).to_stdout
end if success > 0 end if success > 0 # rubocop:disable Style/MultilineIfModifier
it 'outputs upload failures' do it 'outputs upload failures' do
expect { run }.to output(/Error .* I am a teapot/).to_stdout expect { run }.to output(/Error .* I am a teapot/).to_stdout
end if failures > 0 end if failures > 0 # rubocop:disable Style/MultilineIfModifier
end end
it_behaves_like 'outputs correctly', success: 10 it_behaves_like 'outputs correctly', success: 10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment