Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-02-17 01:11:56 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-02-17 13:38:18 +0300
commitb1203108b0eda20f87c75004f035e9e7a51f1124 (patch)
tree3c5664f0eba5aa0626e8896be4917327d7973980 /app/services
parenta9e0301c230a81242d476f30d7089565919214b3 (diff)
Flush all repository caches when deleting a repo
This ensures that _all_ caches (including any caches normally only flushed under certain conditions) are flushed whenever a project is removed. Because cache keys are based on project namespaces (excluding IDs) not doing so could result in a newly created project re-using old caches (if the project was re-created using the same name).
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/destroy_service.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb
index 294157b4f0e..f4dcb142850 100644
--- a/app/services/projects/destroy_service.rb
+++ b/app/services/projects/destroy_service.rb
@@ -16,11 +16,15 @@ module Projects
return false unless can?(current_user, :remove_project, project)
project.team.truncate
- project.repository.expire_cache unless project.empty_repo?
repo_path = project.path_with_namespace
wiki_path = repo_path + '.wiki'
+ # Flush the cache for both repositories. This has to be done _before_
+ # removing the physical repositories as some expiration code depends on
+ # Git data (e.g. a list of branch names).
+ flush_caches(project, wiki_path)
+
Project.transaction do
project.destroy!
@@ -70,5 +74,13 @@ module Projects
def removal_path(path)
"#{path}+#{project.id}#{DELETED_FLAG}"
end
+
+ def flush_caches(project, wiki_path)
+ project.repository.expire_all_caches! if project.repository.exists?
+
+ wiki_repo = Repository.new(wiki_path, project)
+
+ wiki_repo.expire_all_caches! if wiki_repo.exists?
+ end
end
end