Commit 199182fd authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

git_cache: on upload, run "git gc" only if necessary.

If the destination cache file already exists, "git gc" isn't useful.

R=karenqian

Bug: 943696
Change-Id: I1fe3ab04713996b962012242edb6cbdb279f4874
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1585707Reviewed-by: 's avatarKaren Qian <karenqian@google.com>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent c62691b6
......@@ -607,9 +607,6 @@ class Mirror(object):
# The folder is <git number>
gen_number = subprocess.check_output(
[self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip()
# Run Garbage Collect to compress packfile.
self.RunGit(['gc', '--prune=all'])
gsutil = Gsutil(path=self.gsutil_exe, boto_path=None)
src_name = self.mirror_path
......@@ -631,6 +628,9 @@ class Mirror(object):
print('Cache %s already exists' % dest_name)
return
# Run Garbage Collect to compress packfile.
self.RunGit(['gc', '--prune=all'])
gsutil.call('-m', 'cp', '-r', src_name, dest_name)
#TODO(karenqian): prune old caches
......
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