Add a little lockfile for pushdot

This commit is contained in:
Sage Vaillancourt 2024-07-21 12:24:26 -04:00
parent dd6caf8f53
commit cb2185ab3e
1 changed files with 14 additions and 0 deletions

View File

@ -75,6 +75,8 @@ fi
source ~/.shell_aliases
source ~/.zsh_local
SYNC_LOCK_FILE="$HOME/.sync-lock"
# Ignores certain values/sections that shouldn't be synced
function dconf-clean {
local current_section=""
@ -203,6 +205,17 @@ function load-extensions {
function pushdot {
cd "$DOT_DIR" || return 1
if test -f "$SYNC_LOCK_FILE"; then
echo "Sync lockfile present at '$SYNC_LOCK_FILE'"
echo "Waiting for ongoing sync to finish"
for i in {0..60}; do
sleep 1
if ! test -f "$SYNC_LOCK_FILE"; then
break
fi
done
fi
touch "$SYNC_LOCK_FILE"
local res
if ! git diff --quiet; then
if [ $# -eq 0 ]; then
@ -220,6 +233,7 @@ function pushdot {
sync-history
push-dconf
cd -
rm "$SYNC_LOCK_FILE"
return $res
}