diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-16 12:53:35 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-01-31 22:50:40 +0000 |
commit | ac09f857cd9edd4a18280f617b48fe436109ceaa (patch) | |
tree | 834dd6e84d0523a43b331c410171af4db3c3155e /app/workers | |
parent | 732a821d4f00f9812d014b6c58eae2f9a18f7ddd (diff) | |
download | gitlab-ce-ac09f857cd9edd4a18280f617b48fe436109ceaa.tar.gz |
Remove locking and add force to FileUtils methods
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/pages_worker.rb | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/app/workers/pages_worker.rb b/app/workers/pages_worker.rb index c51ec81c9da..59f4b4f16f4 100644 --- a/app/workers/pages_worker.rb +++ b/app/workers/pages_worker.rb @@ -5,7 +5,7 @@ class PagesWorker BLOCK_SIZE = 32.kilobytes MAX_SIZE = 1.terabyte - sidekiq_options queue: :pages + sidekiq_options queue: :pages, retry: false def perform(build_id) @build_id = build_id @@ -44,25 +44,17 @@ class PagesWorker FileUtils.mkdir_p(pages_path) - # Lock file for time of deployment to prevent the two processes from doing the concurrent deployment - File.open(lock_path, File::RDWR|File::CREAT, 0644) do |f| - f.flock(File::LOCK_EX) - return unless valid? - - # Do atomic move of pages - # Move and removal may not be atomic, but they are significantly faster then extracting and removal - # 1. We move deployed public to previous public path (file removal is slow) - # 2. We move temporary public to be deployed public - # 3. We remove previous public path - if File.exists?(public_path) - FileUtils.move(public_path, previous_public_path) - end - FileUtils.move(temp_public_path, public_path) - end - - if File.exists?(previous_public_path) - FileUtils.rm_r(previous_public_path, force: true) - end + # Ignore deployment if the HEAD changed when we were extracting the archive + return unless valid? + + # Do atomic move of pages + # Move and removal may not be atomic, but they are significantly faster then extracting and removal + # 1. We move deployed public to previous public path (file removal is slow) + # 2. We move temporary public to be deployed public + # 3. We remove previous public path + FileUtils.move(public_path, previous_public_path, force: true) + FileUtils.move(temp_public_path, public_path) + FileUtils.rm_r(previous_public_path, force: true) @status.success end |