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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
1c931f07
Commit
1c931f07
authored
Mar 05, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework to minimize changes
parent
2e87923d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
app/services/projects/update_pages_service.rb
app/services/projects/update_pages_service.rb
+15
-8
app/workers/pages_worker.rb
app/workers/pages_worker.rb
+1
-1
No files found.
app/services/projects/update_pages_service.rb
View file @
1c931f07
module
Projects
module
Projects
class
UpdatePagesService
<
BaseService
class
UpdatePagesService
<
BaseService
InvaildStateError
=
Class
.
new
(
StandardError
)
BLOCK_SIZE
=
32
.
kilobytes
BLOCK_SIZE
=
32
.
kilobytes
MAX_SIZE
=
1
.
terabyte
MAX_SIZE
=
1
.
terabyte
SITE_PATH
=
'public/'
.
freeze
SITE_PATH
=
'public/'
.
freeze
...
@@ -11,13 +12,15 @@ module Projects
...
@@ -11,13 +12,15 @@ module Projects
end
end
def
execute
def
execute
register_attempt
# Create status notifying the deployment of pages
# Create status notifying the deployment of pages
@status
=
create_status
@status
=
create_status
@status
.
enqueue!
@status
.
enqueue!
@status
.
run!
@status
.
run!
raise
'missing pages artifacts'
unless
build
.
artifacts?
raise
InvaildStateError
,
'missing pages artifacts'
unless
build
.
artifacts?
raise
'pages are outdated'
unless
latest?
raise
InvaildStateError
,
'pages are outdated'
unless
latest?
# Create temporary directory in which we will extract the artifacts
# Create temporary directory in which we will extract the artifacts
FileUtils
.
mkdir_p
(
tmp_path
)
FileUtils
.
mkdir_p
(
tmp_path
)
...
@@ -26,24 +29,22 @@ module Projects
...
@@ -26,24 +29,22 @@ module Projects
# Check if we did extract public directory
# Check if we did extract public directory
archive_public_path
=
File
.
join
(
archive_path
,
'public'
)
archive_public_path
=
File
.
join
(
archive_path
,
'public'
)
raise
'pages miss the public folder'
unless
Dir
.
exist?
(
archive_public_path
)
raise
InvaildStateError
,
'pages miss the public folder'
unless
Dir
.
exist?
(
archive_public_path
)
raise
'pages are outdated'
unless
latest?
raise
InvaildStateError
,
'pages are outdated'
unless
latest?
deploy_page!
(
archive_public_path
)
deploy_page!
(
archive_public_path
)
success
success
end
end
rescue
=>
e
rescue
InvaildStateError
=>
e
register_failure
register_failure
error
(
e
.
message
)
error
(
e
.
message
)
ensure
register_attempt
build
.
erase_artifacts!
unless
build
.
has_expiring_artifacts?
end
end
private
private
def
success
def
success
@status
.
success
@status
.
success
delete_artifact!
super
super
end
end
...
@@ -52,6 +53,7 @@ module Projects
...
@@ -52,6 +53,7 @@ module Projects
@status
.
allow_failure
=
!
latest?
@status
.
allow_failure
=
!
latest?
@status
.
description
=
message
@status
.
description
=
message
@status
.
drop
(
:script_failure
)
@status
.
drop
(
:script_failure
)
delete_artifact!
super
super
end
end
...
@@ -163,6 +165,11 @@ module Projects
...
@@ -163,6 +165,11 @@ module Projects
build
.
artifacts_file
.
path
build
.
artifacts_file
.
path
end
end
def
delete_artifact!
build
.
reload
build
.
erase_artifacts!
unless
build
.
has_expiring_artifacts?
end
def
latest_sha
def
latest_sha
project
.
commit
(
build
.
ref
).
try
(
:sha
).
to_s
project
.
commit
(
build
.
ref
).
try
(
:sha
).
to_s
end
end
...
...
app/workers/pages_worker.rb
View file @
1c931f07
class
PagesWorker
class
PagesWorker
include
ApplicationWorker
include
ApplicationWorker
sidekiq_options
retry:
false
sidekiq_options
retry:
3
def
perform
(
action
,
*
arg
)
def
perform
(
action
,
*
arg
)
send
(
action
,
*
arg
)
# rubocop:disable GitlabSecurity/PublicSend
send
(
action
,
*
arg
)
# rubocop:disable GitlabSecurity/PublicSend
...
...
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