BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b1378f05
Commit
b1378f05
authored
Jan 08, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rake task to check integrity of uploaded files
parent
8a7bbe1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
uploads.rake
lib/tasks/gitlab/uploads.rake
+44
-0
No files found.
lib/tasks/gitlab/uploads.rake
0 → 100644
View file @
b1378f05
namespace
:gitlab
do
namespace
:uploads
do
desc
'GitLab | Uploads | Check integrity of uploaded files'
task
check: :environment
do
puts
'Starting 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
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