feat: 'disable' renames to sync.json.disabled; new 'enable' rename-back
Pause/resume sync without losing the instance_id.
disable sync.json -> sync.json.disabled
enable sync.json.disabled -> sync.json
Re-enabling preserves the original ULID + url so the same restic
repo continues. No new instance_id minted, no orphaned snapshot
history. Tradeoff vs the previous 'disable = delete' semantics:
the on-disk artifact survives, so a truly fresh start now needs
'disable && rm sync.json.disabled' before 'setup'.
Implementation:
config.disable(pack) os.rename(sync.json -> sync.json.disabled).
False if no sync.json.
config.enable(pack) os.rename(sync.json.disabled -> sync.json).
Refuses if sync.json already exists
(caller must disable first).
config.delete(pack) now sweeps BOTH forms (escape hatch / tests).
setup_flow gains a precheck: if sync.json.disabled is present, point
the user at 'enable' instead of silently minting a fresh ULID over
their existing instance.
Opt-in gate (cfgmod.exists) is unchanged — only literal sync.json
counts. The .disabled sibling is invisible to pull/push, so the
silent-no-op behavior for paused instances Just Works.
cli adds 'enable' subcommand alongside 'disable'. _run_disable prints
'already disabled' when called twice; _run_enable refuses to clobber
an active config (exits 2 with the FileExistsError message).
7 new tests for disable/enable behavior + edge cases (idempotency,
nothing-to-X, refuse-clobber). 80 tests total.
This commit is contained in:
@@ -99,6 +99,12 @@ def test_disable_subcommand_parses() -> None:
|
||||
assert str(ns.pack_folder) == "/tmp/x"
|
||||
|
||||
|
||||
def test_enable_subcommand_parses() -> None:
|
||||
cmd, ns = parse(["enable", "--pack-folder=/tmp/x"])
|
||||
assert cmd == "enable"
|
||||
assert str(ns.pack_folder) == "/tmp/x"
|
||||
|
||||
|
||||
def test_missing_subcommand_exits() -> None:
|
||||
with pytest.raises(SystemExit):
|
||||
parse([])
|
||||
|
||||
Reference in New Issue
Block a user