summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-09-09 14:13:48 -0700
committerStan Hu <stanhu@gmail.com>2019-09-09 14:13:48 -0700
commit7af3835a61bc155da443c16295f73544a17dbfd9 (patch)
treee8cb94229abaf7537cd89a14dcade9db6ec0ac3e
parentc900091cf667e4f5f88c6600dcdf1cb204ef6124 (diff)
downloadgitlab-ce-sh-fix-import-export-shared.tar.gz
Move removing of project export file to after export strategysh-fix-import-export-shared
-rw-r--r--lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb11
-rw-r--r--lib/gitlab/import_export/after_export_strategies/download_notification_strategy.rb4
-rw-r--r--spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb6
-rw-r--r--spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb2
4 files changed, 21 insertions, 2 deletions
diff --git a/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb b/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
index 4dfdd8b27b7..165974a20ff 100644
--- a/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
+++ b/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
@@ -50,6 +50,7 @@ module Gitlab
false
ensure
delete_after_export_lock
+ delete_export_file
end
def to_json(options = {})
@@ -78,8 +79,18 @@ module Gitlab
raise NotImplementedError
end
+ def delete_export?
+ true
+ end
+
private
+ def delete_export_file
+ return if locks_present? || !delete_export?
+
+ project.remove_exports
+ end
+
def create_or_update_after_export_lock
FileUtils.touch(lock_file)
end
diff --git a/lib/gitlab/import_export/after_export_strategies/download_notification_strategy.rb b/lib/gitlab/import_export/after_export_strategies/download_notification_strategy.rb
index 1b391314a74..f8979f71690 100644
--- a/lib/gitlab/import_export/after_export_strategies/download_notification_strategy.rb
+++ b/lib/gitlab/import_export/after_export_strategies/download_notification_strategy.rb
@@ -4,6 +4,10 @@ module Gitlab
module ImportExport
module AfterExportStrategies
class DownloadNotificationStrategy < BaseAfterExportStrategy
+ def delete_export?
+ false
+ end
+
private
def strategy_execute
diff --git a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
index cca65691030..1f4de8037aa 100644
--- a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
+++ b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
@@ -28,6 +28,12 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
end
context 'when the method succeeds' do
+ it 'removes the export file' do
+ expect(project).to receive(:remove_exports)
+
+ service.execute(user, project)
+ end
+
it 'removes the lock file' do
service.execute(user, project)
diff --git a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb
index 21a227335cd..5d5a3188f67 100644
--- a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb
+++ b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb
@@ -30,8 +30,6 @@ describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do
allow(strategy).to receive(:send_file)
allow(strategy).to receive(:handle_response_error)
- expect(project).to receive(:remove_exports)
-
strategy.execute(user, project)
end