summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-09 17:50:09 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-09 17:50:09 +0000
commit4e9add7c2c118a16b205cef9ccf7bfb314116844 (patch)
treeb1518e38f1dc483c44d064098b558c8b6221f993
parentfae6eb63535f6136704365692f4c34ccfd6eba67 (diff)
parent944ebb8e2e06ac916024eed48ab7dc4b29f76de2 (diff)
downloadgitlab-ce-4e9add7c2c118a16b205cef9ccf7bfb314116844.tar.gz
Merge branch 'clean_old_archives' into 'master'
Clean old archives from repository downloads directory
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/repositories_controller.rb2
-rw-r--r--app/models/repository.rb5
3 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 72f2642727a..34ad0df2fb2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@ v 6.8.0
- Allow oauth signup without email for twitter and github
- Fix faulty namespace names that caused 500 on user creation
- Option to disable standard login
+ - Clean old created archives from repository downloads directory
v 6.7.3
- Fix the merge notification email not being sent (Pierre de La Morinerie)
diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb
index d1a6fecba20..28fed8b0e3f 100644
--- a/app/controllers/projects/repositories_controller.rb
+++ b/app/controllers/projects/repositories_controller.rb
@@ -16,6 +16,8 @@ class Projects::RepositoriesController < Projects::ApplicationController
storage_path = Gitlab.config.gitlab.repository_downloads_path
+ @repository.clean_old_archives
+
file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase)
if file_path
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 35ec84f1651..eadc34127c2 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -215,4 +215,9 @@ class Repository
def last_commit_for_path(sha, path)
commits(sha, path, 1).last
end
+
+ # Remove archives older than 2 hours
+ def clean_old_archives
+ Gitlab::Popen.popen(%W(find #{Gitlab.config.gitlab.repository_downloads_path} -mmin +120 -delete))
+ end
end