Share lock with getdot

This commit is contained in:
Sage Vaillancourt 2024-07-21 12:28:35 -04:00
parent cb2185ab3e
commit 82e05fc333
1 changed files with 8 additions and 3 deletions

View File

@ -203,8 +203,7 @@ function load-extensions {
done done
} }
function pushdot { function dot-lock-wait {
cd "$DOT_DIR" || return 1
if test -f "$SYNC_LOCK_FILE"; then if test -f "$SYNC_LOCK_FILE"; then
echo "Sync lockfile present at '$SYNC_LOCK_FILE'" echo "Sync lockfile present at '$SYNC_LOCK_FILE'"
echo "Waiting for ongoing sync to finish" echo "Waiting for ongoing sync to finish"
@ -215,7 +214,12 @@ function pushdot {
fi fi
done done
fi fi
touch "$SYNC_LOCK_FILE" }
function pushdot {
cd "$DOT_DIR" || return 1
dot-lock-wait
echo "$$" > "$SYNC_LOCK_FILE"
local res local res
if ! git diff --quiet; then if ! git diff --quiet; then
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@ -264,6 +268,7 @@ function getdot {
echo "An alias for scpace has not been defined on this device!" echo "An alias for scpace has not been defined on this device!"
return 1 return 1
fi fi
dot-lock-wait
cd "$DOT_DIR" || return 1 cd "$DOT_DIR" || return 1
git pull && ./copy.sh git pull && ./copy.sh