Commit c4f55ce3 authored by Ahmad Sherif's avatar Ahmad Sherif

Migrate Gitlab::Git::Repository#size to Gitaly

Closes gitaly#437
parent b12107a0
...@@ -391,7 +391,7 @@ gem 'vmstat', '~> 2.3.0' ...@@ -391,7 +391,7 @@ gem 'vmstat', '~> 2.3.0'
gem 'sys-filesystem', '~> 1.1.6' gem 'sys-filesystem', '~> 1.1.6'
# Gitaly GRPC client # Gitaly GRPC client
gem 'gitaly', '~> 0.24.0' gem 'gitaly', '~> 0.26.0'
gem 'toml-rb', '~> 0.3.15', require: false gem 'toml-rb', '~> 0.3.15', require: false
......
...@@ -269,7 +269,7 @@ GEM ...@@ -269,7 +269,7 @@ GEM
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
gherkin-ruby (0.3.2) gherkin-ruby (0.3.2)
gitaly (0.24.0) gitaly (0.26.0)
google-protobuf (~> 3.1) google-protobuf (~> 3.1)
grpc (~> 1.0) grpc (~> 1.0)
github-linguist (4.7.6) github-linguist (4.7.6)
...@@ -975,7 +975,7 @@ DEPENDENCIES ...@@ -975,7 +975,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.2.0) gettext_i18n_rails_js (~> 1.2.0)
gitaly (~> 0.24.0) gitaly (~> 0.26.0)
github-linguist (~> 4.7.0) github-linguist (~> 4.7.0)
gitlab-flowdock-git-hook (~> 1.0.1) gitlab-flowdock-git-hook (~> 1.0.1)
gitlab-markup (~> 1.5.1) gitlab-markup (~> 1.5.1)
......
...@@ -282,7 +282,14 @@ module Gitlab ...@@ -282,7 +282,14 @@ module Gitlab
# Return repo size in megabytes # Return repo size in megabytes
def size def size
size = popen(%w(du -sk), path).first.strip.to_i size = gitaly_migrate(:repository_size) do |is_enabled|
if is_enabled
size_by_gitaly
else
size_by_shelling_out
end
end
(size.to_f / 1024).round(2) (size.to_f / 1024).round(2)
end end
...@@ -942,6 +949,14 @@ module Gitlab ...@@ -942,6 +949,14 @@ module Gitlab
gitaly_ref_client.tags gitaly_ref_client.tags
end end
def size_by_shelling_out
popen(%w(du -sk), path).first.strip.to_i
end
def size_by_gitaly
gitaly_repository_client.repository_size
end
def count_commits_by_gitaly(options) def count_commits_by_gitaly(options)
gitaly_commit_client.commit_count(options[:ref], options) gitaly_commit_client.commit_count(options[:ref], options)
end end
......
...@@ -27,6 +27,11 @@ module Gitlab ...@@ -27,6 +27,11 @@ module Gitlab
request = Gitaly::RepackIncrementalRequest.new(repository: @gitaly_repo) request = Gitaly::RepackIncrementalRequest.new(repository: @gitaly_repo)
GitalyClient.call(@storage, :repository_service, :repack_incremental, request) GitalyClient.call(@storage, :repository_service, :repack_incremental, request)
end end
def repository_size
request = Gitaly::RepositorySizeRequest.new(repository: @gitaly_repo)
GitalyClient.call(@storage, :repository_service, :repository_size, request).size
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment