fix: replace removed brctl download with open -g; add -f to mackup restore
brctl download was removed in macOS Sonoma — the remaining subcommands are diagnose/log/dump/status/accounts/quota/monitor. Replace the dead call with a find loop that uses 'open -g <real-path>' to request per-file iCloud download from the daemon, followed by a 1-second settle pause and the existing .icloud stub deletion. Also add -f to mackup restore for consistency with the backup call. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+17
-8
@@ -44,13 +44,21 @@ ssr::mackup::_materialize_icloud() {
|
||||
*Mobile\ Documents*) ;; # only worth doing for iCloud
|
||||
*) return 0 ;;
|
||||
esac
|
||||
# `brctl download` is the documented way to request file materialization.
|
||||
# Available on macOS 10.12+; silently skip if missing on older systems.
|
||||
if command -v brctl >/dev/null 2>&1; then
|
||||
brctl download "$mackup_root" >/dev/null 2>&1 || true
|
||||
fi
|
||||
# Belt-and-braces: prune any stub files that survived the download
|
||||
# request (sometimes left over from interrupted prior runs).
|
||||
# `brctl download` was removed in macOS Sonoma (remaining brctl subcommands:
|
||||
# diagnose/log/dump/status/accounts/quota/monitor). The current way to
|
||||
# trigger per-file iCloud download from the CLI is `open -g <real-path>`,
|
||||
# which asks the iCloud daemon to fetch the file in the background.
|
||||
find "$mackup_root" -name '*.icloud' -type f 2>/dev/null | while IFS= read -r stub; do
|
||||
local dir base real
|
||||
dir="$(dirname "$stub")"
|
||||
base="$(basename "$stub")"
|
||||
real="${base#.}" # strip leading dot
|
||||
real="${real%.icloud}" # strip .icloud suffix
|
||||
open -g "$dir/$real" 2>/dev/null || true
|
||||
done
|
||||
# Brief pause so the iCloud daemon can start fetching before mackup reads.
|
||||
sleep 1
|
||||
# Belt-and-braces: prune any stubs that couldn't be resolved.
|
||||
find "$mackup_root" -name '*.icloud' -type f -delete 2>/dev/null || true
|
||||
}
|
||||
|
||||
@@ -93,5 +101,6 @@ ssr::mackup::backup() {
|
||||
|
||||
ssr::mackup::restore() {
|
||||
ssr::log "mackup restore"
|
||||
mackup restore
|
||||
# -f: answer "yes" to all prompts (consistent with backup behaviour).
|
||||
mackup -f restore
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user