summaryrefslogtreecommitdiff
path: root/app/controllers/import
diff options
context:
space:
mode:
authorJames Lopez <james@gitlab.com>2018-09-17 10:52:49 +0000
committerDouwe Maan <douwe@gitlab.com>2018-09-17 10:52:49 +0000
commite72aeccdae4cdb35c3ab4941bcf3b4f0dd22d41b (patch)
treed06cf884ca34caed2fba77743b931ea6f521e14c /app/controllers/import
parent78b3eea7d248c6d3c48b615c9df24a95cb5fd1d8 (diff)
downloadgitlab-ce-e72aeccdae4cdb35c3ab4941bcf3b4f0dd22d41b.tar.gz
Resolve "Unable to import repository: undefined method `import_file' for nil:NilClass"
Diffstat (limited to 'app/controllers/import')
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb8
1 files changed, 6 insertions, 2 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