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
231e3e3b
Commit
231e3e3b
authored
Feb 27, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce the difference between CE and EE for upload and LFS object checks
parent
c50f3e8e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 addition
and
79 deletions
+1
-79
ee/lib/tasks/gitlab/lfs/migrate.rake
ee/lib/tasks/gitlab/lfs/migrate.rake
+0
-0
ee/lib/tasks/gitlab/uploads/check.rake
ee/lib/tasks/gitlab/uploads/check.rake
+0
-30
ee/lib/tasks/gitlab/uploads/helpers.rb
ee/lib/tasks/gitlab/uploads/helpers.rb
+0
-23
ee/spec/tasks/gitlab/lfs/migrate_rake_spec.rb
ee/spec/tasks/gitlab/lfs/migrate_rake_spec.rb
+1
-1
ee/spec/tasks/gitlab/uploads/check_rake_spec.rb
ee/spec/tasks/gitlab/uploads/check_rake_spec.rb
+0
-25
No files found.
ee/lib/tasks/gitlab/lfs.rake
→
ee/lib/tasks/gitlab/lfs
/migrate
.rake
View file @
231e3e3b
File moved
ee/lib/tasks/gitlab/uploads/check.rake
deleted
100644 → 0
View file @
c50f3e8e
require_relative
'helpers.rb'
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
puts
" * File does not exist on the file system"
.
color
(
:red
)
end
rescue
ObjectStorage
::
RemoteStoreError
puts
"- File (
#{
upload
.
id
}
): File is stored remotely, skipping"
.
color
(
:yellow
)
end
end
end
puts
'Done!'
end
end
end
ee/lib/tasks/gitlab/uploads/helpers.rb
deleted
100644 → 0
View file @
c50f3e8e
module
UploadTaskHelpers
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
ee/spec/tasks/gitlab/lfs_rake_spec.rb
→
ee/spec/tasks/gitlab/lfs
/migrate
_rake_spec.rb
View file @
231e3e3b
...
@@ -2,7 +2,7 @@ require 'rake_helper'
...
@@ -2,7 +2,7 @@ require 'rake_helper'
describe
'gitlab:lfs namespace rake task'
do
describe
'gitlab:lfs namespace rake task'
do
before
:all
do
before
:all
do
Rake
.
application
.
rake_require
'tasks/gitlab/lfs'
Rake
.
application
.
rake_require
'tasks/gitlab/lfs
/migrate
'
end
end
describe
'migrate'
do
describe
'migrate'
do
...
...
ee/spec/tasks/gitlab/uploads/check_rake_spec.rb
deleted
100644 → 0
View file @
c50f3e8e
require
'rake_helper'
describe
'gitlab:uploads:check 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/check'
end
it
'outputs the integrity check for each uploaded file'
do
expect
{
run_rake_task
(
'gitlab:uploads:check'
)
}.
to
output
(
/Checking file \(
#{
upload
.
id
}
\):
#{
Regexp
.
quote
(
upload
.
absolute_path
)
}
/
).
to_stdout
end
it
'errors out about missing files on the file system'
do
create
(
:upload
)
expect
{
run_rake_task
(
'gitlab:uploads:check'
)
}.
to
output
(
/File does not exist on the file system/
).
to_stdout
end
it
'errors out about invalid checksum'
do
upload
.
update_column
(
:checksum
,
'01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e'
)
expect
{
run_rake_task
(
'gitlab:uploads:check'
)
}.
to
output
(
/File checksum \(9e697aa09fe196909813ee36103e34f721fe47a5fdc8aac0e4e4ac47b9b38282\) does not match the one in the database \(
#{
upload
.
checksum
}
\)/
).
to_stdout
end
end
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