Commit b2959c4102b411c9e078ea21fd4b2f5411932290

Authored by Marin Jankovski
1 parent 71678f08

Remove archives older than 2 hours.

app/controllers/projects/repositories_controller.rb
@@ -16,6 +16,8 @@ class Projects::RepositoriesController < Projects::ApplicationController @@ -16,6 +16,8 @@ class Projects::RepositoriesController < Projects::ApplicationController
16 16
17 storage_path = Gitlab.config.gitlab.repository_downloads_path 17 storage_path = Gitlab.config.gitlab.repository_downloads_path
18 18
  19 + @repository.clean_old_archives
  20 +
19 file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase) 21 file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase)
20 22
21 if file_path 23 if file_path
app/models/repository.rb
@@ -215,4 +215,9 @@ class Repository @@ -215,4 +215,9 @@ class Repository
215 def last_commit_for_path(sha, path) 215 def last_commit_for_path(sha, path)
216 commits(sha, path, 1).last 216 commits(sha, path, 1).last
217 end 217 end
  218 +
  219 + # Remove archives older than 2 hours
  220 + def clean_old_archives
  221 + Gitlab::Popen.popen(%W(find #{Gitlab.config.gitlab.repository_downloads_path} -mmin +120 -delete))
  222 + end
218 end 223 end