summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/saver.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 21:06:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 21:06:20 +0000
commit0c3f12149372a79b825d265a6c28dc547e4a1afc (patch)
tree43bdaa20afb0b061d09c56d8507efd51d28601be /lib/gitlab/import_export/saver.rb
parentff67e3ed08355fb2d6f6e69d4ed06cd09052e573 (diff)
downloadgitlab-ce-0c3f12149372a79b825d265a6c28dc547e4a1afc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/import_export/saver.rb')
-rw-r--r--lib/gitlab/import_export/saver.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/gitlab/import_export/saver.rb b/lib/gitlab/import_export/saver.rb
index bea7a7cce65..ae82c380755 100644
--- a/lib/gitlab/import_export/saver.rb
+++ b/lib/gitlab/import_export/saver.rb
@@ -9,16 +9,16 @@ module Gitlab
new(*args).save
end
- def initialize(project:, shared:)
- @project = project
- @shared = shared
+ def initialize(exportable:, shared:)
+ @exportable = exportable
+ @shared = shared
end
def save
if compress_and_save
remove_export_path
- Rails.logger.info("Saved project export #{archive_file}") # rubocop:disable Gitlab/RailsLogger
+ Rails.logger.info("Saved #{@exportable.class} export #{archive_file}") # rubocop:disable Gitlab/RailsLogger
save_upload
else
@@ -48,11 +48,11 @@ module Gitlab
end
def archive_file
- @archive_file ||= File.join(@shared.archive_path, Gitlab::ImportExport.export_filename(project: @project))
+ @archive_file ||= File.join(@shared.archive_path, Gitlab::ImportExport.export_filename(exportable: @exportable))
end
def save_upload
- upload = ImportExportUpload.find_or_initialize_by(project: @project)
+ upload = initialize_upload
File.open(archive_file) { |file| upload.export_file = file }
@@ -62,6 +62,12 @@ module Gitlab
def error_message
"Unable to save #{archive_file} into #{@shared.export_path}."
end
+
+ def initialize_upload
+ exportable_kind = @exportable.class.name.downcase
+
+ ImportExportUpload.find_or_initialize_by(Hash[exportable_kind, @exportable])
+ end
end
end
end