Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1b5c238a
Commit
1b5c238a
authored
Jan 26, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove lint
parent
c2faf5ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
+12
-11
lib/tasks/gitlab/uploads/check.rake
lib/tasks/gitlab/uploads/check.rake
+3
-3
lib/tasks/gitlab/uploads/migrate.rake
lib/tasks/gitlab/uploads/migrate.rake
+4
-3
spec/tasks/gitlab/uploads_rake_spec.rb
spec/tasks/gitlab/uploads_rake_spec.rb
+5
-5
No files found.
lib/tasks/gitlab/uploads/check.rake
View file @
1b5c238a
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
...
...
lib/tasks/gitlab/uploads/migrate.rake
View file @
1b5c238a
...
@@ -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
)
...
...
spec/tasks/gitlab/uploads_rake_spec.rb
View file @
1b5c238a
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment