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:
@@ -48,13 +48,19 @@ python /path/to/cloud-sync.pyz init \
|
||||
|
||||
That mints a fresh `instance_id` (ULID), writes `.cloud-sync/sync.json` (the opt-in marker) and `.cloud-sync/token` (mode 600). Subsequent launches sync automatically via the global hook.
|
||||
|
||||
**Opting out:**
|
||||
**Opting out / pausing:**
|
||||
|
||||
```
|
||||
python /path/to/cloud-sync.pyz disable --pack-folder=/path/to/instance/minecraft
|
||||
```
|
||||
|
||||
Removes `sync.json` (cloud data untouched). Instance returns to no-op behavior.
|
||||
Renames `sync.json` → `sync.json.disabled`. Instance returns to no-op behavior (the opt-in gate only sees a literal `sync.json`). Re-enable later with:
|
||||
|
||||
```
|
||||
python /path/to/cloud-sync.pyz enable --pack-folder=/path/to/instance/minecraft
|
||||
```
|
||||
|
||||
That rename-back preserves the original `instance_id` so snapshots continue against the same restic repo — no fresh ULID, no orphaned history. For a truly fresh start, `disable` then delete `sync.json.disabled` by hand before re-running `setup`.
|
||||
|
||||
Player needs Python 3.10+ AND a Qt binding (`pip install PySide6`). Without Qt the pyz falls back to headless mode for status; the conflict + login dialogs are Qt-only — without them, conflict aborts the launch defensively and `setup` prompts for the token via stdin.
|
||||
|
||||
@@ -70,7 +76,8 @@ instance-sync pull / push [--pack-folder=PATH]
|
||||
|
||||
instance-sync setup [--url=URL] [--pack-folder=PATH] # interactive
|
||||
instance-sync init --url=URL [--token=ID:PASS] ... # scripted
|
||||
instance-sync disable [--pack-folder=PATH]
|
||||
instance-sync disable [--pack-folder=PATH] # sync.json → sync.json.disabled
|
||||
instance-sync enable [--pack-folder=PATH] # sync.json.disabled → sync.json
|
||||
```
|
||||
|
||||
`pull` and `push` don't take `--url` — it's loaded from `sync.json`. `--instance-label` overrides the UI display name (defaults to `$INST_NAME` from Prism, then `$INST_ID`, then the first 8 chars of `instance_id`).
|
||||
|
||||
Reference in New Issue
Block a user