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
b5f5b6dc
Commit
b5f5b6dc
authored
Feb 26, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checksum to ci_job_artifacts
parent
2e87923d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
0 deletions
+24
-0
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+5
-0
app/uploaders/job_artifact_uploader.rb
app/uploaders/job_artifact_uploader.rb
+10
-0
db/migrate/20180226050030_add_checksum_to_ci_job_artifacts.rb
...igrate/20180226050030_add_checksum_to_ci_job_artifacts.rb
+8
-0
db/schema.rb
db/schema.rb
+1
-0
No files found.
app/models/ci/job_artifact.rb
View file @
b5f5b6dc
...
...
@@ -6,6 +6,7 @@ module Ci
belongs_to
:job
,
class_name:
"Ci::Build"
,
foreign_key: :job_id
before_save
:set_size
,
if: :file_changed?
before_save
:set_checksum
,
if: :file_changed?
mount_uploader
:file
,
JobArtifactUploader
...
...
@@ -25,6 +26,10 @@ module Ci
self
.
size
=
file
.
size
end
def
set_checksum
self
.
checksum
=
file
.
checksum
end
def
expire_in
expire_at
-
Time
.
now
if
expire_at
end
...
...
app/uploaders/job_artifact_uploader.rb
View file @
b5f5b6dc
...
...
@@ -9,6 +9,12 @@ class JobArtifactUploader < GitlabUploader
model
.
size
end
def
checksum
return
calc_checksum
if
model
.
checksum
.
nil?
model
.
checksum
end
def
store_dir
dynamic_segment
end
...
...
@@ -21,6 +27,10 @@ class JobArtifactUploader < GitlabUploader
private
def
calc_checksum
Digest
::
SHA256
.
file
(
file
.
path
).
hexdigest
end
def
dynamic_segment
creation_date
=
model
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
...
...
db/migrate/20180226050030_add_checksum_to_ci_job_artifacts.rb
0 → 100644
View file @
b5f5b6dc
class
AddChecksumToCiJobArtifacts
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
change
add_column
:ci_job_artifacts
,
:checksum
,
:string
,
limit:
64
end
end
db/schema.rb
View file @
b5f5b6dc
...
...
@@ -346,6 +346,7 @@ ActiveRecord::Schema.define(version: 20180304204842) do
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
datetime_with_timezone
"expire_at"
t
.
string
"file"
t
.
string
"checksum"
,
limit:
64
end
add_index
"ci_job_artifacts"
,
[
"expire_at"
,
"job_id"
],
name:
"index_ci_job_artifacts_on_expire_at_and_job_id"
,
using: :btree
...
...
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