Commit 4e9add7c2c118a16b205cef9ccf7bfb314116844

Authored by Dmitriy Zaporozhets
2 parents fae6eb63 944ebb8e

Merge branch 'clean_old_archives' into 'master'

Clean old archives from repository downloads directory
@@ -13,6 +13,7 @@ v 6.8.0 @@ -13,6 +13,7 @@ v 6.8.0
13 - Allow oauth signup without email for twitter and github 13 - Allow oauth signup without email for twitter and github
14 - Fix faulty namespace names that caused 500 on user creation 14 - Fix faulty namespace names that caused 500 on user creation
15 - Option to disable standard login 15 - Option to disable standard login
  16 + - Clean old created archives from repository downloads directory
16 17
17 v 6.7.3 18 v 6.7.3
18 - Fix the merge notification email not being sent (Pierre de La Morinerie) 19 - Fix the merge notification email not being sent (Pierre de La Morinerie)
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