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

remove lint

parent c2faf5ba
require_relative 'helpers.rb'
include UploadTaskHelpers
namespace :gitlab do
namespace :uploads do
desc 'GitLab | Uploads | Check integrity of uploaded files'
task check: :environment do
include UploadTaskHelpers
puts 'Checking integrity of uploaded files'
uploads_batches do |batch|
batch.each do |upload|
begin
puts "- Checking file (#{upload.id}): #{upload.absolute_path}".color(:green)
if upload.exist?
check_checksum(upload)
else
......
......@@ -58,9 +58,10 @@ module UploadTask
def migrate(batch_size, &block)
each_upload_batch(batch_size) do |batch|
results = build_uploaders(batch)
.map(&method(:process_uploader))
results = build_uploaders(batch).map(&method(:process_uploader))
yield results # yield processed batch as [MigrationResult]
@results.concat(results)
end
end
......@@ -74,7 +75,7 @@ module UploadTask
.where.not(store: @to_store)
.where(uploader: @uploader_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
def process_uploader(uploader)
......
......@@ -5,7 +5,7 @@ describe 'gitlab:uploads rake tasks' do
let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) }
before do
Rake.application.rake_require 'tasks/gitlab/uploads'
Rake.application.rake_require 'tasks/gitlab/uploads/check'
end
it 'outputs the integrity check for each uploaded file' do
......@@ -33,7 +33,7 @@ describe 'gitlab:uploads rake tasks' do
let(:batch_size) { 3 }
before do
ENV['BATCH'] = batch_size.to_s
stub_env('BATCH', batch_size.to_s)
stub_uploads_object_storage(uploader_class)
Rake.application.rake_require 'tasks/gitlab/uploads/migrate'
end
......@@ -50,15 +50,15 @@ describe 'gitlab:uploads rake tasks' do
batch_count = [batch_size, total].min
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
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
expect { run }.to output(/Error .* I am a teapot/).to_stdout
end if failures > 0
end if failures > 0 # rubocop:disable Style/MultilineIfModifier
end
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