fix(scripts): resolve race condition in state-sync and mark stress test as complete
All checks were successful
Check / eval-and-lint (push) Successful in 7m9s
All checks were successful
Check / eval-and-lint (push) Successful in 7m9s
This commit is contained in:
@@ -90,20 +90,18 @@ LOCK_FILE="${STATE_FILE}.lock"
|
||||
# Validate JSON before moving
|
||||
if jq empty "$TMP_FILE" 2>/dev/null; then
|
||||
mv "$TMP_FILE" "$STATE_FILE"
|
||||
|
||||
# Sync to the Nix configuration while still holding the lock.
|
||||
# This prevents desyncs where a newer JSON state is overwritten by an
|
||||
# older Nix state during concurrent writes.
|
||||
if [[ "$STATE_FILE" == "$HOME/.config/nomarchy/state.json" ]]; then
|
||||
if command -v nomarchy-sync-nix-state >/dev/null 2>&1; then
|
||||
nomarchy-sync-nix-state
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Error: Failed to generate valid JSON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
) 200>"$LOCK_FILE"
|
||||
|
||||
# Clean up lock file
|
||||
rm -f "$LOCK_FILE"
|
||||
|
||||
# If we just updated the main home state file, sync it to the Nix configuration.
|
||||
# This bridges the gap between runtime UI changes and declarative Nix.
|
||||
if [[ "$STATE_FILE" == "$HOME/.config/nomarchy/state.json" ]]; then
|
||||
if command -v nomarchy-sync-nix-state >/dev/null 2>&1; then
|
||||
nomarchy-sync-nix-state
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user