From: Joey Hess Date: Mon, 5 Oct 2020 18:07:27 +0000 (-0400) Subject: move cache cleanup to avoid a race X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~112^2~19 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=12a248f823fe6e278ed3336fa6834958b1f8e321;p=git-annex.git move cache cleanup to avoid a race This should fix doc/bugs/standalone_runshell_can_race_and_fail_to_remove___96____126____47__.cache__47__git-annex__47__locales__47____96___dirs where 2 runshells were running and the second one tried to clean up LOCPATH while the first one was still populating it. By moving the cleanup until after LOCPATH is populated, we guarantee it's populated, so don't need to worry about such a race with another process populating our same LOCPATH. --- diff --git a/standalone/linux/skel/runshell b/standalone/linux/skel/runshell index c63b05413c..08661d3e21 100755 --- a/standalone/linux/skel/runshell +++ b/standalone/linux/skel/runshell @@ -141,14 +141,6 @@ if [ -z "${LOCPATH+set}" ] && [ -z "$GIT_ANNEX_PACKAGE_INSTALL" ]; then fi export LOCPATH - # Clean up locale caches when their standalone bundle no longer exists. - for localecache in $HOME/.cache/git-annex/locales/*; do - cachebase=$(cat "$localecache/base" 2>/dev/null || true) - if [ ! -d "$cachebase" ] || ! cmp "$localecache/buildid" "$cachebase/buildid" >/dev/null 2>&1 ; then - rm -rf "$localecache" >/dev/null 2>&1 || true - fi - done - if [ ! -d "$LOCPATH" ]; then if ! mkdir -p "$LOCPATH"; then echo "Unable to write to $LOCPATH; can't continue!" >&2 @@ -195,6 +187,14 @@ if [ -z "${LOCPATH+set}" ] && [ -z "$GIT_ANNEX_PACKAGE_INSTALL" ]; then fi fi done + + # Clean up locale caches when their standalone bundle no longer exists. + for localecache in $HOME/.cache/git-annex/locales/*; do + cachebase=$(cat "$localecache/base" 2>/dev/null || true) + if [ ! -d "$cachebase" ] || ! cmp "$localecache/buildid" "$cachebase/buildid" >/dev/null 2>&1 ; then + rm -rf "$localecache" >/dev/null 2>&1 || true + fi + done fi useproot=""