diff options
author | Gavin Mak <gavinmak@google.com> | 2023-05-30 20:04:07 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-30 20:25:00 +0000 |
commit | 945c006f406550add8a3cad32ada0791f5a15c53 (patch) | |
tree | 2c304555efb276d433d01c1418b092cd7a944faa /subcmds/sync.py | |
parent | 71122f941f99cea6001c143feedf34a8dbb2a2a2 (diff) | |
download | git-repo-945c006f406550add8a3cad32ada0791f5a15c53.tar.gz |
sync: Update sync progress even when _sync_dict is emptyv2.34.1
By chance, _sync_dict can be empty even though repo sync is still
working. In that case, the progress message shows incorrect info. Handle this case and fix a bug where "0 jobs" can show.
Bug: http://b/284465096
Change-Id: If915d953ba60e7cf84a6fb2d137fd6ed82abd3cc
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375494
Tested-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 0e4f34c0..224d9885 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -679,16 +679,20 @@ later is required to fix a server side protocol bug. | |||
679 | def _GetSyncProgressMessage(self): | 679 | def _GetSyncProgressMessage(self): |
680 | earliest_time = float("inf") | 680 | earliest_time = float("inf") |
681 | earliest_proj = None | 681 | earliest_proj = None |
682 | for project, t in self._sync_dict.items(): | 682 | items = self._sync_dict.items() |
683 | for project, t in items: | ||
683 | if t < earliest_time: | 684 | if t < earliest_time: |
684 | earliest_time = t | 685 | earliest_time = t |
685 | earliest_proj = project | 686 | earliest_proj = project |
686 | 687 | ||
687 | if not earliest_proj: | 688 | if not earliest_proj: |
688 | return None | 689 | # This function is called when sync is still running but in some |
690 | # cases (by chance), _sync_dict can contain no entries. Return some | ||
691 | # text to indicate that sync is still working. | ||
692 | return "..working.." | ||
689 | 693 | ||
690 | elapsed = time.time() - earliest_time | 694 | elapsed = time.time() - earliest_time |
691 | jobs = jobs_str(len(self._sync_dict)) | 695 | jobs = jobs_str(len(items)) |
692 | return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}" | 696 | return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}" |
693 | 697 | ||
694 | def _Fetch(self, projects, opt, err_event, ssh_proxy): | 698 | def _Fetch(self, projects, opt, err_event, ssh_proxy): |