Commit 4e9add7c2c118a16b205cef9ccf7bfb314116844

Authored by Dmitriy Zaporozhets
2 parents fae6eb63 944ebb8e

Merge branch 'clean_old_archives' into 'master'

Clean old archives from repository downloads directory
CHANGELOG
... ... @@ -13,6 +13,7 @@ v 6.8.0
13 13 - Allow oauth signup without email for twitter and github
14 14 - Fix faulty namespace names that caused 500 on user creation
15 15 - Option to disable standard login
  16 + - Clean old created archives from repository downloads directory
16 17  
17 18 v 6.7.3
18 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 16  
17 17 storage_path = Gitlab.config.gitlab.repository_downloads_path
18 18  
  19 + @repository.clean_old_archives
  20 +
19 21 file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase)
20 22  
21 23 if file_path
... ...
app/models/repository.rb
... ... @@ -215,4 +215,9 @@ class Repository
215 215 def last_commit_for_path(sha, path)
216 216 commits(sha, path, 1).last
217 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 223 end
... ...