Linux standalone: Use md5sum to shorten paths in .cache/git-annex/locales

md5sum is part of busybox, so is probably available unless it were compiled
out. If md5sum (or cut for that matter) is not available, it will
still use the whole path to $base, otherwise hash it.

Of course it's possible for md5sum to be available sometimes and not others
on the same system; in such an event the locales would be built twice for
the same bundle. The cleanup code will delete both sets once that
version of the bundle is upgraded.
This commit is contained in:
Joey Hess 2020-03-04 13:04:56 -04:00
parent 4f01a4e2e0
commit 88f721549d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 8 additions and 0 deletions

View file

@ -129,6 +129,11 @@ ORIG_LOCPATH="$LOCPATH"
export ORIG_LOCPATH
if [ -z "${LOCPATH+set}" ] && [ -z "$GIT_ANNEX_PACKAGE_INSTALL" ]; then
LOCPATH="$HOME/.cache/git-annex/locales/$(echo "$base" | tr / _ )"
# try to generate a short version, if md5sum is available
locpathmd5=$( (echo "$LOCPATH" | md5sum | cut -d ' ' -f 1 2>/dev/null) || true)
if [ -n "$locpathmd5" ]; then
LOCPATH="$HOME/.cache/git-annex/locales/$locpathmd5"
fi
export LOCPATH
# Clean up locale caches when their standalone bundle no longer exists.