diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-13 21:28:22 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-13 21:28:22 +0300 |
commit | 1d63464c82db58763a0941c22ab8c3c973890a38 (patch) | |
tree | 98249433ecd93975e3326f42744c9c6217b879ce /app | |
parent | d8b769ec740f9e6d47c3885d99796e4ca9337cbc (diff) | |
download | gitlab-ce-1d63464c82db58763a0941c22ab8c3c973890a38.tar.gz |
Fix repository archive
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/repositories_controller.rb | 6 | ||||
-rw-r--r-- | app/services/archive_repository_service.rb | 14 |
2 files changed, 15 insertions, 5 deletions
diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index f76ddb34bc4..f30eaadd928 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -14,11 +14,7 @@ class Projects::RepositoriesController < Projects::ApplicationController render_404 and return end - storage_path = Gitlab.config.gitlab.repository_downloads_path - - @repository.clean_old_archives - - file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase) + file_path = ArchiveRepositoryService.new.execute(@project, params[:ref], params[:format]) if file_path # Send file to user diff --git a/app/services/archive_repository_service.rb b/app/services/archive_repository_service.rb new file mode 100644 index 00000000000..8823f6fdc67 --- /dev/null +++ b/app/services/archive_repository_service.rb @@ -0,0 +1,14 @@ +class ArchiveRepositoryService + def execute(project, ref, format) + storage_path = Gitlab.config.gitlab.repository_downloads_path + + unless File.directory?(storage_path) + FileUtils.mkdir_p(storage_path) + end + + format ||= 'tar.gz' + repository = project.repository + repository.clean_old_archives + repository.archive_repo(ref, storage_path, format.downcase) + end +end |