diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2017-04-19 10:12:09 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@gitlab.com> | 2017-05-01 11:14:24 +0200 |
commit | 39efd0c03018089366d5301583a605626e97e9d7 (patch) | |
tree | a963ff9a85fa264e705bfce8e58945f923f0eb00 /lib/gitlab | |
parent | 389057f00184a3549a1874174cbb81c807abfd49 (diff) | |
download | gitlab-ce-39efd0c03018089366d5301583a605626e97e9d7.tar.gz |
Clear cached markdown after renaming projects
Diffstat (limited to 'lib/gitlab')
3 files changed, 24 insertions, 3 deletions
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb b/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb index 4d454fd8ea0..fa0c93084e3 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb @@ -90,6 +90,24 @@ module Gitlab FileUtils.mv(old_path, new_path) end + def remove_cached_html_for_projects(project_ids) + update_column_in_batches(:projects, :description_html, nil) do |table, query| + query.where(table[:id].in(project_ids)) + end + + update_column_in_batches(:issues, :description_html, nil) do |table, query| + query.where(table[:project_id].in(project_ids)) + end + + update_column_in_batches(:merge_requests, :description_html, nil) do |table, query| + query.where(table[:target_project_id].in(project_ids)) + end + + update_column_in_batches(:notes, :note_html, nil) do |table, query| + query.where(table[:project_id].in(project_ids)) + end + end + def file_storage? CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File end diff --git a/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb b/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb index 847b6e56955..4937dfe2d31 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb @@ -27,6 +27,7 @@ module Gitlab move_repositories(namespace, old_full_path, new_full_path) move_uploads(old_full_path, new_full_path) move_pages(old_full_path, new_full_path) + remove_cached_html_for_projects(projects_for_namespace(namespace).map(&:id)) end def move_repositories(namespace, old_full_path, new_full_path) @@ -55,8 +56,6 @@ module Gitlab MigrationClasses::Project.where(namespace_or_children) end - # This won't scale to huge trees, but it should do for a handful of - # namespaces called `system`. def child_ids_for_parent(namespace, ids: []) namespace.children.each do |child| ids << child.id diff --git a/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb b/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb index 49b9453b134..4f35c3371d8 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb @@ -8,6 +8,8 @@ module Gitlab projects_for_paths.each do |project| rename_project(project) end + + remove_cached_html_for_projects(projects_for_paths.map(&:id)) end def rename_project(project) @@ -28,10 +30,12 @@ module Gitlab end def projects_for_paths + return @projects_for_paths if @projects_for_paths + with_paths = MigrationClasses::Route.arel_table[:path] .matches_any(path_patterns) - MigrationClasses::Project.joins(:route).where(with_paths) + @projects_for_paths = MigrationClasses::Project.joins(:route).where(with_paths) end end end |