summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-09-17 10:52:49 +0000
committerJan Provaznik <jprovaznik@gitlab.com>2018-09-18 10:21:32 +0200
commitfe746e13fbf6e125c04c4af0e5235cbfa584ea3e (patch)
tree0a736117d4aa3b06019162489978f4b90371cb97 /app
parentd6233127329ee97e90a9da2487c85069f7e51ea3 (diff)
downloadgitlab-ce-fe746e13fbf6e125c04c4af0e5235cbfa584ea3e.tar.gz
Merge branch '50944-unable-to-import-repository-undefined-method-import_file-for-nil-nilclass' into 'master'11-3-stable-prepare-rc10
Resolve "Unable to import repository: undefined method `import_file' for nil:NilClass" Closes #50944 See merge request gitlab-org/gitlab-ce!21765
Diffstat (limited to 'app')
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb8
-rw-r--r--app/controllers/projects_controller.rb2
2 files changed, 7 insertions, 3 deletions
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index f22df992fe9..f21c38a4c27 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -11,7 +11,7 @@ class Import::GitlabProjectsController < Import::BaseController
def create
unless file_is_valid?
- return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." })
+ return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive (ending in .gz)." })
end
@project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute
@@ -29,7 +29,11 @@ class Import::GitlabProjectsController < Import::BaseController
private
def file_is_valid?
- project_params[:file] && project_params[:file].respond_to?(:read)
+ return false unless project_params[:file] && project_params[:file].respond_to?(:read)
+
+ filename = project_params[:file].original_filename
+
+ ImportExportUploader::EXTENSION_WHITELIST.include?(File.extname(filename).delete('.'))
end
def verify_gitlab_project_import_enabled
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 98076791ab9..e40f3dab882 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -192,7 +192,7 @@ class ProjectsController < Projects::ApplicationController
def download_export
if @project.export_file_exists?
- send_upload(@project.export_file)
+ send_upload(@project.export_file, attachment: @project.export_file.filename)
else
redirect_to(
edit_project_path(@project, anchor: 'js-export-project'),