From 200eeea2587d36a90f8308425887e953c48eecbc Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 28 Mar 2014 13:09:25 +0100 Subject: [PATCH] Make the repository downloads path configurable --- CHANGELOG | 1 + app/controllers/projects/repositories_controller.rb | 2 +- config/gitlab.yml.example | 4 ++++ config/initializers/1_settings.rb | 1 + lib/api/repositories.rb | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 19219915789..e3ab6a5e924 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ v 6.8.0 - Make user search case-insensitive (Christopher Arnold) - Remove omniauth-ldap nickname bug workaround - Drop all tables before restoring a Postgres backup + - Make the repository downloads path configurable v 6.7.2 - Fix upgrader script diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index f686db70bd4..d1a6fecba20 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -14,7 +14,7 @@ class Projects::RepositoriesController < Projects::ApplicationController render_404 and return end - storage_path = Rails.root.join("tmp", "repositories") + storage_path = Gitlab.config.gitlab.repository_downloads_path file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase) diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 9364181eaa4..cb4b8c73a42 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -76,6 +76,10 @@ production: &base snippets: false visibility_level: "private" # can be "private" | "internal" | "public" + ## Repository downloads directory + # When a user clicks e.g. 'Download zip' on a project, a temporary zip file is created in the following directory. + # repository_downloads_path: tmp/repositories + ## External issues trackers issues_tracker: # redmine: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index cf6c79bb50e..70ba26cea7a 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -97,6 +97,7 @@ Settings.gitlab.default_projects_features['wiki'] = true if Settings.g Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil? Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil? Settings.gitlab.default_projects_features['visibility_level'] = Settings.send(:verify_constant, Gitlab::VisibilityLevel, Settings.gitlab.default_projects_features['visibility_level'], Gitlab::VisibilityLevel::PRIVATE) +Settings.gitlab['repository_downloads_path'] = File.absolute_path(Settings.gitlab['repository_downloads_path'] || 'tmp/repositories', Rails.root) # # Gravatar diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index ba53bf9baa4..53482c3b7f2 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -161,7 +161,7 @@ module API repo = user_project.repository ref = params[:sha] format = params[:format] - storage_path = Rails.root.join("tmp", "repositories") + storage_path = Gitlab.config.gitlab.repository_downloads_path file_path = repo.archive_repo(ref, storage_path, format) if file_path && File.exists?(file_path)