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/+/1585707
Reviewed-by: Karen Qian <karenqian@google.com>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
changes/07/1585707/2
Andrii Shyshkalov 6 years ago committed by Commit Bot
parent c62691b671
commit 199182fd64

@ -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

Loading…
Cancel
Save