diff options
author | Robert Speicher <robert@gitlab.com> | 2017-08-07 21:29:32 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-08-07 21:29:32 +0000 |
commit | 6085ce1352eee7b3e18b014f0f68719cae780da8 (patch) | |
tree | 5a110cc7ed6302f9db29cc3fd09cb77babe2d538 /lib | |
parent | c94990820a2ea3cfc16099e318fcce5354a3c052 (diff) | |
parent | c4f55ce32d6160b43c518954219cca69077b5001 (diff) | |
download | gitlab-ce-6085ce1352eee7b3e18b014f0f68719cae780da8.tar.gz |
Merge branch 'feature/migrate-repository-size-to-gitaly' into 'master'
Migrate Gitlab::Git::Repository#size to Gitaly
Closes gitaly#437
See merge request !13259
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/repository.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 5 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index f6f9d49bf37..f246393cfbc 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -282,7 +282,14 @@ module Gitlab # Return repo size in megabytes 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) end @@ -943,6 +950,14 @@ module Gitlab gitaly_ref_client.tags 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) gitaly_commit_client.commit_count(options[:ref], options) end diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index 13e75b256a7..79ce784f2f2 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -27,6 +27,11 @@ module Gitlab request = Gitaly::RepackIncrementalRequest.new(repository: @gitaly_repo) GitalyClient.call(@storage, :repository_service, :repack_incremental, request) end + + def repository_size + request = Gitaly::RepositorySizeRequest.new(repository: @gitaly_repo) + GitalyClient.call(@storage, :repository_service, :repository_size, request).size + end end end end |