From 8cc72531f47694b740287084d20905c2cecf2298 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Thu, 29 Jun 2017 18:05:36 -0300 Subject: [PATCH 1/2] Expires full_path cache after renaming a repository --- app/models/concerns/routable.rb | 11 +++++++++-- app/models/project.rb | 1 + spec/models/project_spec.rb | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index 30bda65374b9dd..8ba2fe692e4a54 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -103,8 +103,11 @@ def full_name def full_path return uncached_full_path unless RequestStore.active? - key = "routable/full_path/#{self.class.name}/#{self.id}" - RequestStore[key] ||= uncached_full_path + RequestStore[full_path_key] ||= uncached_full_path + end + + def expires_full_path_cache + RequestStore.delete(full_path_key) if RequestStore.active? end def build_full_path @@ -135,6 +138,10 @@ def full_path_changed? path_changed? || parent_changed? end + def full_path_key + @full_path_key ||= "routable/full_path/#{self.class.name}/#{self.id}" + end + def build_full_name if parent && name parent.human_name + ' / ' + name diff --git a/app/models/project.rb b/app/models/project.rb index 8253621f28934e..cab984ac95cf5b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -972,6 +972,7 @@ def rename_repo begin gitlab_shell.mv_repository(repository_storage_path, "#{old_path_with_namespace}.wiki", "#{new_path_with_namespace}.wiki") send_move_instructions(old_path_with_namespace) + expires_full_path_cache @old_path_with_namespace = old_path_with_namespace diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 840e6327a51947..53b65c560ebb33 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1457,6 +1457,8 @@ def create_pipeline expect(project).to receive(:expire_caches_before_rename) + expect(project).to receive(:expires_full_path_cache) + project.rename_repo end -- GitLab From 3e700b48eb14d60adcfd4d929a283d3268a16722 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Thu, 29 Jun 2017 18:24:05 -0300 Subject: [PATCH 2/2] Add CHANGELOG --- changelogs/unreleased-ee/fix-2801.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelogs/unreleased-ee/fix-2801.yml diff --git a/changelogs/unreleased-ee/fix-2801.yml b/changelogs/unreleased-ee/fix-2801.yml new file mode 100644 index 00000000000000..4f1ba1832394db --- /dev/null +++ b/changelogs/unreleased-ee/fix-2801.yml @@ -0,0 +1,4 @@ +--- +title: Geo - Fix project rename on secondary nodes +merge_request: +author: -- GitLab