summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/saver.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-05-10 17:15:20 +0200
committerJames Lopez <james@jameslopez.es>2016-05-10 17:15:20 +0200
commita5d59f075a4a9a301ef985eb7cc6cdfdf3e73955 (patch)
tree4ba912caf343c7a1d0fd77894f368a400065aec5 /lib/gitlab/import_export/saver.rb
parent6a12ff6345e517af9cf07cb61f3a0ea85562f399 (diff)
downloadgitlab-ce-a5d59f075a4a9a301ef985eb7cc6cdfdf3e73955.tar.gz
added better error handling. Also refactored some of the code and fixed a few issues in project_tree_saver
Diffstat (limited to 'lib/gitlab/import_export/saver.rb')
-rw-r--r--lib/gitlab/import_export/saver.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/gitlab/import_export/saver.rb b/lib/gitlab/import_export/saver.rb
index 634e58e6039..024a0e1e785 100644
--- a/lib/gitlab/import_export/saver.rb
+++ b/lib/gitlab/import_export/saver.rb
@@ -7,32 +7,35 @@ module Gitlab
new(*args).save
end
- def initialize(storage_path:)
- @storage_path = storage_path
+ def initialize(shared:)
+ @shared = shared
end
def save
if compress_and_save
- remove_storage_path
+ remove_@shared.storage_path
Rails.logger.info("Saved project export #{archive_file}")
archive_file
else
false
end
+ rescue => e
+ @shared.error(e.message)
+ false
end
private
def compress_and_save
- tar_czf(archive: archive_file, dir: @storage_path)
+ tar_czf(archive: archive_file, dir: @shared.storage_path)
end
- def remove_storage_path
- FileUtils.rm_rf(@storage_path)
+ def remove_shared.storage_path
+ FileUtils.rm_rf(@shared.storage_path)
end
def archive_file
- @archive_file ||= File.join(@storage_path, '..', "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_project_export.tar.gz")
+ @archive_file ||= File.join(@shared.storage_path, '..', "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_project_export.tar.gz")
end
end
end