From cb2185ab3eccf866422a384928e86b4519c36a8f Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:24:26 -0400 Subject: [PATCH] Add a little lockfile for pushdot --- fake_home/.zshrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index c74f5e0..6197d64 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -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 }