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
Boxiang Sun
gitlab-ce
Commits
35dd2e12
Commit
35dd2e12
authored
Dec 16, 2015
by
Kamil Trzcinski
Committed by
James Edwards-Jones
Jan 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
d28f1a7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
app/workers/pages_worker.rb
app/workers/pages_worker.rb
+11
-5
No files found.
app/workers/pages_worker.rb
View file @
35dd2e12
...
@@ -14,23 +14,26 @@ class PagesWorker
...
@@ -14,23 +14,26 @@ class PagesWorker
# Create status notifying the deployment of pages
# Create status notifying the deployment of pages
@status
=
create_status
@status
=
create_status
@status
.
run!
@status
.
run!
raise
'pages are outdated'
unless
latest?
raise
'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
)
Dir
.
mktmpdir
(
nil
,
tmp_path
)
do
|
archive_path
|
Dir
.
mktmpdir
(
nil
,
tmp_path
)
do
|
archive_path
|
results
=
extract_archive
(
archive_path
)
extract_archive!
(
archive_path
)
raise
'pages failed to extract'
unless
results
.
all?
(
&
:success?
)
# 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
.
exists?
(
archive_public_path
)
raise
'pages miss the public folder'
unless
Dir
.
exists?
(
archive_public_path
)
raise
'pages are outdated'
unless
latest?
raise
'pages are outdated'
unless
latest?
deploy_page!
(
archive_public_path
)
deploy_page!
(
archive_public_path
)
@status
.
success
@status
.
success
end
end
rescue
=>
e
rescue
=>
e
fail
(
e
.
message
,
!
latest?
)
fail
(
e
.
message
,
!
latest?
)
return
false
end
end
private
private
...
@@ -46,12 +49,12 @@ class PagesWorker
...
@@ -46,12 +49,12 @@ class PagesWorker
)
)
end
end
def
extract_archive
(
temp_path
)
def
extract_archive
!
(
temp_path
)
results
=
Open3
.
pipeline
(
%W(gunzip -c
#{
artifacts
}
)
,
results
=
Open3
.
pipeline
(
%W(gunzip -c
#{
artifacts
}
)
,
%W(dd bs=
#{
BLOCK_SIZE
}
count=
#{
blocks
}
)
,
%W(dd bs=
#{
BLOCK_SIZE
}
count=
#{
blocks
}
)
,
%W(tar -x -C
#{
temp_path
}
public/)
,
%W(tar -x -C
#{
temp_path
}
public/)
,
err:
'/dev/null'
)
err:
'/dev/null'
)
r
esults
.
compact
r
aise
'pages failed to extract'
unless
results
.
compact
.
all?
(
&
:success?
)
end
end
def
deploy_page!
(
archive_public_path
)
def
deploy_page!
(
archive_public_path
)
...
@@ -61,7 +64,10 @@ class PagesWorker
...
@@ -61,7 +64,10 @@ class PagesWorker
# 2. We move temporary public to be deployed public
# 2. We move temporary public to be deployed public
# 3. We remove previous public path
# 3. We remove previous public path
FileUtils
.
mkdir_p
(
pages_path
)
FileUtils
.
mkdir_p
(
pages_path
)
FileUtils
.
move
(
public_path
,
previous_public_path
,
force:
true
)
begin
FileUtils
.
move
(
public_path
,
previous_public_path
)
rescue
end
FileUtils
.
move
(
archive_public_path
,
public_path
)
FileUtils
.
move
(
archive_public_path
,
public_path
)
ensure
ensure
FileUtils
.
rm_r
(
previous_public_path
,
force:
true
)
FileUtils
.
rm_r
(
previous_public_path
,
force:
true
)
...
...
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