fix(deploy): managed symlinks changing owners relink silently; quarantine reserved for genuine divergence

This commit is contained in:
Frank
2026-09-10 20:41:14 -07:00
parent 0883ae5660
commit c8cac879e6
+13 -8
View File
@@ -47,16 +47,21 @@ deploy_file() { # $1 = repo file path, $2 = home-relative target path
if [ -L "$tgt" ]; then
if [ "$(realpath "$tgt")" = "$(realpath "$src")" ]; then return 0; fi # already deployed
case "$MODE" in
check) echo "DRIFT $2 (symlink points elsewhere: $(realpath "$tgt"))" ;;
check) echo "RELINK $2 (managed symlink changing owners)" ;;
adopt) echo "SKIP $2 (foreign symlink, --adopt does not overwrite)" ; skipped=$((skipped+1)) ;;
sync)
ts="$(date +%Y%m%d-%H%M%S)-$$"
dest="$QUAR/$HOST/$ts/$2"
mkdir -p "$(dirname "$dest")"
mv -- "$tgt" "$dest"
ln -sfn "$(realpath "$src")" "$tgt"
actions=$((actions+1)); quarantined=$((quarantined+1))
echo "QUAR $2 -> .quarantine/$HOST/$ts/$2"
if [[ "$(realpath "$tgt")" == "$REPO/"* ]]; then
# managed file changing owners between packages: silent relink, nothing to quarantine
ln -sfn "$(realpath "$src")" "$tgt"; actions=$((actions+1))
else
ts="$(date +%Y%m%d-%H%M%S)-$$"
dest="$QUAR/$HOST/$ts/$2"
mkdir -p "$(dirname "$dest")"
mv -- "$tgt" "$dest"
ln -sfn "$(realpath "$src")" "$tgt"
actions=$((actions+1)); quarantined=$((quarantined+1))
echo "QUAR $2 -> .quarantine/$HOST/$ts/$2"
fi
;;
esac
return 0