From 51f8352dcad8108a5af9a65c85e99a3e5a00103e Mon Sep 17 00:00:00 2001
From: Jacob Vosmaer <contact@jacobvosmaer.nl>
Date: Mon, 29 Sep 2014 17:02:45 +0200
Subject: [PATCH] Keep tmp/repositories during clean-up

---
 CHANGELOG                | 1 +
 app/models/repository.rb | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3006ff4049d..2e02d5ad20d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@ v 7.4.0
   - Refactor test coverage tools usage. Use SIMPLECOV=true to generate it locally
   - Increase unicorn timeout to 60 seconds
   - Sort search autocomplete projects by stars count so most popular go first
+  - Do not delete tmp/repositories itself during clean-up, only its contents
 
 v 7.3.1
   - Fix ref parsing in Gitlab::GitAccess
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 4108c4ee96e..ed220ae2e8d 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -230,7 +230,8 @@ class Repository
 
   # Remove archives older than 2 hours
   def clean_old_archives
-    Gitlab::Popen.popen(%W(find #{Gitlab.config.gitlab.repository_downloads_path} -mmin +120 -delete))
+    repository_downloads_path = Gitlab.config.gitlab.repository_downloads_path
+    Gitlab::Popen.popen(%W(find #{repository_downloads_path} -not -path #{repository_downloads_path} -mmin +120 -delete))
   end
 
   def branches_sorted_by(value)
-- 
GitLab