blob: e64892dfa0357428da071d9c74e73eea337b92ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# frozen_string_literal: true
class ProjectWiki < Wiki
self.container_class = Project
alias_method :project, :container
# Project wikis are tied to the main project storage
delegate :storage, :repository_storage, :hashed_storage?, :lfs_enabled?, to: :container
override :disk_path
def disk_path(*args, &block)
container.disk_path + '.wiki'
end
override :create_wiki_repository
def create_wiki_repository
super
track_wiki_repository
end
override :after_wiki_activity
def after_wiki_activity
# Update activity columns, this is done synchronously to avoid
# replication delays in Geo.
project.touch(:last_activity_at, :last_repository_updated_at)
end
override :after_post_receive
def after_post_receive
# Update storage statistics
ProjectCacheWorker.perform_async(project.id, [], [:wiki_size])
# This call is repeated for post-receive, to make sure we're updating
# the activity columns for Git pushes as well.
after_wiki_activity
end
private
def track_wiki_repository
return unless ::Gitlab::Database.read_write?
return if container.wiki_repository
# This is the ActiveRecord auto-generated method for a Project's has_one :wiki_repository
container.create_wiki_repository!
end
end
# TODO: Remove this once we implement ES support for group wikis.
# https://gitlab.com/gitlab-org/gitlab/-/issues/207889
ProjectWiki.prepend_mod_with('ProjectWiki')
|