summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-07-27 17:56:25 +0200
committerJames Lopez <james@jameslopez.es>2016-08-01 09:15:11 +0200
commit52bb564812d106124b95c93f5a502f3ced9c280b (patch)
tree46faee0a5d107242333f8c26dba90a2452453db5 /lib
parent2f344eca42f1f0fa8ac122316687bc166c489bf1 (diff)
downloadgitlab-ce-52bb564812d106124b95c93f5a502f3ced9c280b.tar.gz
squashed - fix timing issues in prod importing projects
added changelog fix specs refactored code based on feedback fix rubocop warning
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/import_export/file_importer.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/gitlab/import_export/file_importer.rb b/lib/gitlab/import_export/file_importer.rb
index 82d1e1805c5..ff7174c995f 100644
--- a/lib/gitlab/import_export/file_importer.rb
+++ b/lib/gitlab/import_export/file_importer.rb
@@ -3,6 +3,8 @@ module Gitlab
class FileImporter
include Gitlab::ImportExport::CommandLineUtil
+ MAX_RETRIES = 8
+
def self.import(*args)
new(*args).import
end
@@ -14,7 +16,10 @@ module Gitlab
def import
FileUtils.mkdir_p(@shared.export_path)
- decompress_archive
+
+ wait_for_archived_file do
+ decompress_archive
+ end
rescue => e
@shared.error(e)
false
@@ -22,6 +27,19 @@ module Gitlab
private
+ # Exponentially sleep until I/O finishes copying the file
+ def wait_for_archived_file
+ MAX_RETRIES.times do |retry_number|
+ if File.exist?(@archive_file)
+ yield
+
+ break
+ else
+ sleep(2**retry_number)
+ end
+ end
+ end
+
def decompress_archive
result = untar_zxf(archive: @archive_file, dir: @shared.export_path)