From a112f6ba87f9ae4ba6193ec62c9b50f9453454db Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 10 Jun 2020 02:00:19 -0700 Subject: [PATCH] gc-util-functions: add boilerplate combine_packs_std function Put the boilerplate arguments for a call to combine_packs that's intended to actually combine and replace packs in its own function in gc-util-function.sh. Update gc.sh to use it. Signed-off-by: Kyle J. McKay --- jobd/gc-util-functions.sh | 12 ++++++++++++ jobd/gc.sh | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/jobd/gc-util-functions.sh b/jobd/gc-util-functions.sh index 71c64f7..edb0eda 100755 --- a/jobd/gc-util-functions.sh +++ b/jobd/gc-util-functions.sh @@ -16,6 +16,18 @@ run_combine_packs() { PATH="$var_git_exec_path:$cfg_basedir/bin:$PATH" @basedir@/jobd/combine-packs.sh "$@" } +# combine the input pack(s) into a new pack (or possibly packs if packSizeLimit set) +# input pack names are read from standard input one per line delimited by the first +# ':', ' ' or '\n' character on the line (which allows gfi-packs to be read directly) +# all arguments, if any, are passed to pack-objects as additional options +# first removes any pre-existing "*.zap*" sentinels that may be leftover from any +# previously aborted "--replace" operations +# returns non-zero on failure +combine_packs_std() { + find -L objects/pack -maxdepth 1 -type f -name '*.zap*' -exec rm -f '{}' + || : + run_combine_packs --replace "$@" $packopts --all-progress-implied $quiet --non-empty +} + # duplicate the first file to the name given by the second file making sure that # the second file appears atomically all-at-once after the copy has been completed # and does not appear at all if the copy fails (in which case this function fails) diff --git a/jobd/gc.sh b/jobd/gc.sh index c6d315a..f7694bd 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -194,8 +194,7 @@ is_dirty() { # returns non-zero on failure AND creates .gc_failed in that case combine_packs() { rm -f .gc_failed - find -L objects/pack -maxdepth 1 -type f -name '*.zap*' -exec rm -f '{}' + || : - run_combine_packs --replace "$@" $packopts --all-progress-implied $quiet --non-empty || { + combine_packs_std "$@" || { >.gc_failed return 1 } -- 2.11.4.GIT