summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-08 17:07:55 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-08 17:07:55 +0000
commitce06415cb6af38b5dab88d1babfe1888213a0684 (patch)
treee59b262d8499a977d5d567158d9266e74755ca72
parent14c0dc168a0e1fe2dfe67e6f9b20ff4adb431000 (diff)
parent00ce8756ad18987eee622c9aaaa888bc0207ed1d (diff)
downloadgitlab-ce-ce06415cb6af38b5dab88d1babfe1888213a0684.tar.gz
Merge branch 'gitaly-700-wiki-update-page' into 'master'
Migrate GitLab::Git::Wiki.update_page to Gitaly Closes gitaly#700 See merge request gitlab-org/gitlab-ce!15268
-rw-r--r--GITALY_SERVER_VERSION2
-rw-r--r--lib/gitlab/git/wiki.rb25
-rw-r--r--lib/gitlab/gitaly_client/wiki_service.rb25
3 files changed, 46 insertions, 6 deletions
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION
index c5d4cee36a1..4f9b378b40f 100644
--- a/GITALY_SERVER_VERSION
+++ b/GITALY_SERVER_VERSION
@@ -1 +1 @@
-0.51.0
+0.52.0
diff --git a/lib/gitlab/git/wiki.rb b/lib/gitlab/git/wiki.rb
index fe901d049d4..5d36f16abd4 100644
--- a/lib/gitlab/git/wiki.rb
+++ b/lib/gitlab/git/wiki.rb
@@ -48,11 +48,14 @@ module Gitlab
end
def update_page(page_path, title, format, content, commit_details)
- assert_type!(format, Symbol)
- assert_type!(commit_details, CommitDetails)
-
- gollum_wiki.update_page(gollum_page_by_path(page_path), title, format, content, commit_details.to_h)
- nil
+ @repository.gitaly_migrate(:wiki_update_page) do |is_enabled|
+ if is_enabled
+ gitaly_update_page(page_path, title, format, content, commit_details)
+ gollum_wiki.clear_cache
+ else
+ gollum_update_page(page_path, title, format, content, commit_details)
+ end
+ end
end
def pages
@@ -149,6 +152,14 @@ module Gitlab
nil
end
+ def gollum_update_page(page_path, title, format, content, commit_details)
+ assert_type!(format, Symbol)
+ assert_type!(commit_details, CommitDetails)
+
+ gollum_wiki.update_page(gollum_page_by_path(page_path), title, format, content, commit_details.to_h)
+ nil
+ end
+
def gollum_find_page(title:, version: nil, dir: nil)
if version
version = Gitlab::Git::Commit.find(@repository, version).id
@@ -172,6 +183,10 @@ module Gitlab
gitaly_wiki_client.write_page(name, format, content, commit_details)
end
+ def gitaly_update_page(page_path, title, format, content, commit_details)
+ gitaly_wiki_client.update_page(page_path, title, format, content, commit_details)
+ end
+
def gitaly_delete_page(page_path, commit_details)
gitaly_wiki_client.delete_page(page_path, commit_details)
end
diff --git a/lib/gitlab/gitaly_client/wiki_service.rb b/lib/gitlab/gitaly_client/wiki_service.rb
index 15f0f30d303..1a668338f57 100644
--- a/lib/gitlab/gitaly_client/wiki_service.rb
+++ b/lib/gitlab/gitaly_client/wiki_service.rb
@@ -37,6 +37,31 @@ module Gitlab
end
end
+ def update_page(page_path, title, format, content, commit_details)
+ request = Gitaly::WikiUpdatePageRequest.new(
+ repository: @gitaly_repo,
+ page_path: GitalyClient.encode(page_path),
+ title: GitalyClient.encode(title),
+ format: format.to_s,
+ commit_details: gitaly_commit_details(commit_details)
+ )
+
+ strio = StringIO.new(content)
+
+ enum = Enumerator.new do |y|
+ until strio.eof?
+ chunk = strio.read(MAX_MSG_SIZE)
+ request.content = GitalyClient.encode(chunk)
+
+ y.yield request
+
+ request = Gitaly::WikiUpdatePageRequest.new
+ end
+ end
+
+ GitalyClient.call(@repository.storage, :wiki_service, :wiki_update_page, enum)
+ end
+
def delete_page(page_path, commit_details)
request = Gitaly::WikiDeletePageRequest.new(
repository: @gitaly_repo,