diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 03:09:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 03:09:33 +0300 |
commit | b56027c9d80ac0e297ba8a43c81e8504172dbf9f (patch) | |
tree | b85f743277145e930ae195664655d696e6e0a7fc /app | |
parent | 7915c41e4261719719e791602c8235574157164c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/import/gitea_controller.rb | 18 | ||||
-rw-r--r-- | app/controllers/projects/import/jira_controller.rb | 10 | ||||
-rw-r--r-- | app/models/snippet.rb | 9 |
3 files changed, 26 insertions, 11 deletions
diff --git a/app/controllers/import/gitea_controller.rb b/app/controllers/import/gitea_controller.rb index f0888e08622..42c23fb29a7 100644 --- a/app/controllers/import/gitea_controller.rb +++ b/app/controllers/import/gitea_controller.rb @@ -3,6 +3,8 @@ class Import::GiteaController < Import::GithubController extend ::Gitlab::Utils::Override + before_action :verify_blocked_uri, only: :status + def new if session[access_token_key].present? && provider_url.present? redirect_to status_import_url @@ -16,13 +18,7 @@ class Import::GiteaController < Import::GithubController # Must be defined or it will 404 def status - if blocked_url? - session[access_token_key] = nil - - redirect_to new_import_url, alert: _('Specified URL cannot be used.') - else - super - end + super end private @@ -61,8 +57,8 @@ class Import::GiteaController < Import::GithubController { host: provider_url, api_version: 'v1' } end - def blocked_url? - Gitlab::UrlBlocker.blocked_url?( + def verify_blocked_uri + Gitlab::UrlBlocker.validate!( provider_url, { allow_localhost: allow_local_requests?, @@ -70,6 +66,10 @@ class Import::GiteaController < Import::GithubController schemes: %w(http https) } ) + rescue Gitlab::UrlBlocker::BlockedUrlError => e + session[access_token_key] = nil + + redirect_to new_import_url, alert: _('Specified URL cannot be used: "%{reason}"') % { reason: e.message } end def allow_local_requests? diff --git a/app/controllers/projects/import/jira_controller.rb b/app/controllers/projects/import/jira_controller.rb index 03ae17e18be..6af630a9528 100644 --- a/app/controllers/projects/import/jira_controller.rb +++ b/app/controllers/projects/import/jira_controller.rb @@ -22,8 +22,14 @@ module Projects end def import - response = ::JiraImport::StartImportService.new(current_user, @project, jira_import_params[:jira_project_key]).execute - flash[:notice] = response.message if response.message.present? + jira_project_key = jira_import_params[:jira_project_key] + + if jira_project_key.present? + response = ::JiraImport::StartImportService.new(current_user, @project, jira_project_key).execute + flash[:notice] = response.message if response.message.present? + else + flash[:alert] = 'No jira project key has been provided.' + end redirect_to project_import_jira_path(@project) end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 973bdc54111..cfe1c77ec48 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -262,6 +262,15 @@ class Snippet < ApplicationRecord @repository ||= Repository.new(full_path, self, shard: repository_storage, disk_path: disk_path, repo_type: Gitlab::GlRepository::SNIPPET) end + def repository_size_checker + strong_memoize(:repository_size_checker) do + ::Gitlab::RepositorySizeChecker.new( + current_size_proc: -> { repository._uncached_size.megabytes }, + limit: Gitlab::CurrentSettings.snippet_size_limit + ) + end + end + def storage @storage ||= Storage::Hashed.new(self, prefix: Storage::Hashed::SNIPPET_REPOSITORY_PATH_PREFIX) end |