fix: remove dangling symlinks before mackup backup
shutil.copy fails on dangling symlinks with [Errno 2] No such file or directory (e.g. ~/.claude/debug/latest → missing target). Pre-backup cleanup now handles two cases: - Unix sockets (-type s) → Errno 102 - Dangling links (-type l !-e) → Errno 2 Both are ephemeral runtime artefacts that cannot be meaningfully backed up. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+13
-3
@@ -202,9 +202,10 @@ ssr::mackup::backup() {
|
||||
fi
|
||||
[[ -n "$mackup_root" ]] && ssr::mackup::_materialize_icloud "$mackup_root"
|
||||
|
||||
# Unix socket files (type s) cannot be copied and are always recreated
|
||||
# by their owning app on startup. Remove them from $HOME before backup
|
||||
# to prevent shutil.Error: [Errno 102] Operation not supported on socket.
|
||||
# Pre-backup cleanup: remove file types that shutil.copy cannot handle.
|
||||
#
|
||||
# 1. Unix socket files (-type s) — runtime artefacts, recreated on app start.
|
||||
# Cause: shutil.Error [Errno 102] Operation not supported on socket
|
||||
local socket_count
|
||||
socket_count="$(find "$HOME" -type s 2>/dev/null | wc -l | tr -d ' ')"
|
||||
if [[ "$socket_count" -gt 0 ]]; then
|
||||
@@ -212,6 +213,15 @@ ssr::mackup::backup() {
|
||||
find "$HOME" -type s -delete 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 2. Dangling symlinks (-type l ! -e) — point to a non-existent target.
|
||||
# Cause: shutil.Error [Errno 2] No such file or directory: '<target>'
|
||||
local dangling_count
|
||||
dangling_count="$(find "$HOME" -type l ! -e 2>/dev/null | wc -l | tr -d ' ')"
|
||||
if [[ "$dangling_count" -gt 0 ]]; then
|
||||
ssr::log "Removing $dangling_count dangling symlink(s) before mackup backup"
|
||||
find "$HOME" -type l ! -e -delete 2>/dev/null || true
|
||||
fi
|
||||
|
||||
local attempt rc=0
|
||||
for attempt in 1 2 3; do
|
||||
if mackup -f backup; then
|
||||
|
||||
Reference in New Issue
Block a user