Commit 8769b7ab9774c0daa040f114e604141ad294e0e2

Authored by Dmitriy Zaporozhets
2 parents 0488e34b eeeaaa4b

Merge branch 'repo_downloads_dir' into 'master'

Configurable repo downloads path
CHANGELOG
... ... @@ -4,6 +4,7 @@ v 6.8.0
4 4 - Make user search case-insensitive (Christopher Arnold)
5 5 - Remove omniauth-ldap nickname bug workaround
6 6 - Drop all tables before restoring a Postgres backup
  7 + - Make the repository downloads path configurable
7 8  
8 9 v 6.7.2
9 10 - Fix upgrader script
... ...
app/controllers/projects/repositories_controller.rb
... ... @@ -14,7 +14,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
14 14 render_404 and return
15 15 end
16 16  
17   - storage_path = Rails.root.join("tmp", "repositories")
  17 + storage_path = Gitlab.config.gitlab.repository_downloads_path
18 18  
19 19 file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase)
20 20  
... ...
config/gitlab.yml.example
... ... @@ -76,6 +76,11 @@ production: &base
76 76 snippets: false
77 77 visibility_level: "private" # can be "private" | "internal" | "public"
78 78  
  79 + ## Repository downloads directory
  80 + # When a user clicks e.g. 'Download zip' on a project, a temporary zip file is created in the following directory.
  81 + # The default is 'tmp/repositories' relative to the root of the Rails app.
  82 + # repository_downloads_path: tmp/repositories
  83 +
79 84 ## External issues trackers
80 85 issues_tracker:
81 86 # redmine:
... ...
config/initializers/1_settings.rb
... ... @@ -97,6 +97,7 @@ Settings.gitlab.default_projects_features['wiki'] = true if Settings.g
97 97 Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil?
98 98 Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil?
99 99 Settings.gitlab.default_projects_features['visibility_level'] = Settings.send(:verify_constant, Gitlab::VisibilityLevel, Settings.gitlab.default_projects_features['visibility_level'], Gitlab::VisibilityLevel::PRIVATE)
  100 +Settings.gitlab['repository_downloads_path'] = File.absolute_path(Settings.gitlab['repository_downloads_path'] || 'tmp/repositories', Rails.root)
100 101  
101 102 #
102 103 # Gravatar
... ...
lib/api/repositories.rb
... ... @@ -161,7 +161,7 @@ module API
161 161 repo = user_project.repository
162 162 ref = params[:sha]
163 163 format = params[:format]
164   - storage_path = Rails.root.join("tmp", "repositories")
  164 + storage_path = Gitlab.config.gitlab.repository_downloads_path
165 165  
166 166 file_path = repo.archive_repo(ref, storage_path, format)
167 167 if file_path && File.exists?(file_path)
... ...