fix(mackup): update backup path and enhance configuration handling
- Corrected the backup path in the `_in_backup` function to reflect the new structure under `mackup/`. - Improved error handling in `ssr::mackup::configure` to skip restore if the configuration file is not updated, providing user feedback. - Updated `ssr::sync` to conditionally execute backup based on configuration validity, enhancing robustness. - Revised documentation in configuration examples to clarify the new Mackup directory structure and its implications for users.
This commit is contained in:
+11
-12
@@ -238,7 +238,8 @@ ssr::mackup::generate_custom_cfg() {
|
||||
return 1
|
||||
}
|
||||
# Return true when <path> is already present in the Mackup cloud backup.
|
||||
_in_backup() { [[ -e "$mackup_dir/$1" ]]; }
|
||||
# SSR seeds ~/.mackup.cfg with directory=mackup — data lives under that subdir.
|
||||
_in_backup() { [[ -e "$mackup_dir/mackup/$1" ]]; }
|
||||
|
||||
local -a items=()
|
||||
|
||||
@@ -288,23 +289,21 @@ ssr::mackup::ensure_installed() {
|
||||
}
|
||||
|
||||
# Writes ~/.mackup.cfg pointing the engine at the cloud directory.
|
||||
# Idempotent: rewrites only if content differs.
|
||||
# Never overwrites an existing different file without confirmation: shows a
|
||||
# unified diff, then prompts (TTY) or requires SSR_ALLOW_CONF_OVERWRITE=yes.
|
||||
ssr::mackup::configure() {
|
||||
local mackup_dir="$1"
|
||||
local cfg="$HOME/.mackup.cfg"
|
||||
local desired
|
||||
local desired tmp
|
||||
desired="$(printf '[storage]\nengine = file_system\npath = %s\ndirectory = mackup\n' "$mackup_dir")"
|
||||
|
||||
if [[ -f "$cfg" ]] && [[ "$(cat "$cfg")" == "$desired" ]]; then
|
||||
tmp="$(mktemp "${TMPDIR:-/tmp}/ssr-mackup-cfg.XXXXXX")"
|
||||
printf '%s\n' "$desired" > "$tmp"
|
||||
if ssr::replace_file_with_confirm "$cfg" "$tmp"; then
|
||||
rm -f "$tmp"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -L "$cfg" || -f "$cfg" ]]; then
|
||||
cp -f "$cfg" "$cfg.bak.$(date +%s)" 2>/dev/null || true
|
||||
rm -f "$cfg"
|
||||
fi
|
||||
printf '%s\n' "$desired" > "$cfg"
|
||||
ssr::ok "Wrote $cfg"
|
||||
rm -f "$tmp"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Force iCloud Drive to materialize placeholder (.icloud) files under the
|
||||
|
||||
Reference in New Issue
Block a user