summaryrefslogtreecommitdiff
path: root/app/workers/pages_worker.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-12-16 17:09:11 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-01-31 22:50:40 +0000
commit35dd2e12837ea507a02aca239fc7f78f949e9e99 (patch)
treeb36c54f4ea8a13c300dc3327f92833e9807ac245 /app/workers/pages_worker.rb
parentd28f1a7f4aa4bdf664e04a43022667e4e7637e73 (diff)
downloadgitlab-ce-35dd2e12837ea507a02aca239fc7f78f949e9e99.tar.gz
Fix tests
Diffstat (limited to 'app/workers/pages_worker.rb')
-rw-r--r--app/workers/pages_worker.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/workers/pages_worker.rb b/app/workers/pages_worker.rb
index c34259c15f1..6c6bb7ed13f 100644
--- a/app/workers/pages_worker.rb
+++ b/app/workers/pages_worker.rb
@@ -14,23 +14,26 @@ class PagesWorker
# Create status notifying the deployment of pages
@status = create_status
@status.run!
+
raise 'pages are outdated' unless latest?
# Create temporary directory in which we will extract the artifacts
+ FileUtils.mkdir_p(tmp_path)
Dir.mktmpdir(nil, tmp_path) do |archive_path|
- results = extract_archive(archive_path)
- raise 'pages failed to extract' unless results.all?(&:success?)
+ extract_archive!(archive_path)
# Check if we did extract public directory
archive_public_path = File.join(archive_path, 'public')
raise 'pages miss the public folder' unless Dir.exists?(archive_public_path)
raise 'pages are outdated' unless latest?
+
deploy_page!(archive_public_path)
@status.success
end
rescue => e
fail(e.message, !latest?)
+ return false
end
private
@@ -46,12 +49,12 @@ class PagesWorker
)
end
- def extract_archive(temp_path)
+ def extract_archive!(temp_path)
results = Open3.pipeline(%W(gunzip -c #{artifacts}),
%W(dd bs=#{BLOCK_SIZE} count=#{blocks}),
%W(tar -x -C #{temp_path} public/),
err: '/dev/null')
- results.compact
+ raise 'pages failed to extract' unless results.compact.all?(&:success?)
end
def deploy_page!(archive_public_path)
@@ -61,7 +64,10 @@ class PagesWorker
# 2. We move temporary public to be deployed public
# 3. We remove previous public 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)
ensure
FileUtils.rm_r(previous_public_path, force: true)