diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-06-26 17:58:36 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-06-26 17:58:36 -0400 |
commit | 1960b05f63774b500f311c40e6c3c6efd9208848 (patch) | |
tree | 14158c0a61fef34b80a700a6c554d9b184baa3dd | |
parent | f8f25627aef6f46fd95a27400876725fe51343a4 (diff) | |
download | grokmirror-1960b05f63774b500f311c40e6c3c6efd9208848.tar.gz |
Remove empty siblings from consideration
Avoid unnecessary looping on empty (orphaned) siblings.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | grokmirror/fsck.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/grokmirror/fsck.py b/grokmirror/fsck.py index 236311f..d6eb8d8 100755 --- a/grokmirror/fsck.py +++ b/grokmirror/fsck.py @@ -754,7 +754,11 @@ def fsck_mirror(config, verbose=False, force=False, repack_only=False, mdest = None rcount = 0 # Who has the most remotes? - for sibling in siblings: + for sibling in set(siblings): + if sibling not in amap or not len(amap[sibling]): + # Orphaned sibling, ignore it -- it will get cleaned up + siblings.remove(sibling) + continue s_remotes = grokmirror.list_repo_remotes(sibling) if len(s_remotes) > rcount: mdest = sibling @@ -798,6 +802,8 @@ def fsck_mirror(config, verbose=False, force=False, repack_only=False, # XXX: Theoretically, nothing should have cloned a new repo while we were migrating, because # they should have found a better candidate as well. logger.info('%s: deleting (no longer used by anything)', os.path.basename(obstrepo)) + if obstrepo in amap: + amap.pop(obstrepo) shutil.rmtree(obstrepo) continue |