diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-08-31 13:50:53 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-08-31 13:50:53 -0400 |
commit | f818bea5a78d2cb136d6cd7566f602bc18b83080 (patch) | |
tree | 05e059ab07a80c790ce9c5d632184378b391ba46 | |
parent | 7c6fb23d8e70e0b06883373b92f66b580cfff745 (diff) | |
download | grokmirror-f818bea5a78d2cb136d6cd7566f602bc18b83080.tar.gz |
Do a repack instead of fsck if repo fp changed
Instead of running a fsck at nextcheck time, see if the fingerprint has
changed or not and run a git repack instead, to help keep space usage
down.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | grokmirror/fsck.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/grokmirror/fsck.py b/grokmirror/fsck.py index 75afec0..19716ee 100755 --- a/grokmirror/fsck.py +++ b/grokmirror/fsck.py @@ -744,9 +744,18 @@ def fsck_mirror(config, force=False, repack_only=False, conn_only=False, elif repack_all_quick and count_loose > 0: logger.debug('repack_level=1 due to repack_all_quick') repack_level = 1 - else: + elif status[fullpath].get('fingerprint') != grokmirror.get_repo_fingerprint(toplevel, gitdir): logger.debug('Checking repack level of %s', fullpath) repack_level = get_repack_level(obj_info) + else: + repack_level = None + + # trigger a level-1 repack if it's regular check time and the fingerprint has changed + if (not repack_level and schedcheck <= today + and status[fullpath].get('fingerprint') != grokmirror.get_repo_fingerprint(toplevel, gitdir)): + status[fullpath]['nextcheck'] = nextcheck.strftime('%F') + logger.info(' aged: %s (forcing repack)', fullpath) + repack_level = 1 # If we're not already repacking the repo, run a prune if we find garbage in it if obj_info['garbage'] != '0' and not repack_level and is_safe_to_prune(fullpath, config): @@ -1036,6 +1045,9 @@ def fsck_mirror(config, force=False, repack_only=False, conn_only=False, status[fullpath]['nextcheck'] = nextcheck.strftime('%F') logger.info(' next: %s', status[fullpath]['nextcheck']) + gitdir = '/' + os.path.relpath(fullpath, toplevel) + status[fullpath]['fingerprint'] = grokmirror.get_repo_fingerprint(toplevel, gitdir) + # noinspection PyTypeChecker elapsed = int(time.time()-startt) status[fullpath]['s_elapsed'] = elapsed |