Skip to content

Add restore prefix remapping for fresh-system restores#74

Merged
olxgdm merged 13 commits into
mainfrom
73-add-restore-prefix-remapping-for-fresh-system-restores
Jun 25, 2026
Merged

Add restore prefix remapping for fresh-system restores#74
olxgdm merged 13 commits into
mainfrom
73-add-restore-prefix-remapping-for-fresh-system-restores

Conversation

@olxgdm

@olxgdm olxgdm commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #73.

This PR adds restore-only prefix remapping so backups registered under an old absolute path can be restored into an equivalent location on a new machine, user account, or home directory layout.

New supported forms:

cfgsync restore --all --from-prefix <old-prefix> --to-prefix <new-prefix>
cfgsync restore <tracked-file> --from-prefix <old-prefix> --to-prefix <new-prefix>

What Changed

  • Added --from-prefix and --to-prefix options to cfgsync restore.
  • Requires the two remap flags to be provided together.
  • Normalizes remap prefixes through the existing path utilities, including ~ expansion.
  • Keeps single-file restore lookup based on the tracked original path from the registry.
  • Computes remapped destinations only at restore time by replacing the tracked entry's old prefix with the new prefix.
  • Preserves existing restore behavior when remap flags are absent.
  • Leaves registry.json, stored backup paths, and registry version unchanged.
  • Adds an explicit-destination restore overload in StorageManager while preserving the existing original-destination restore API.
  • Documents the fresh-system remap workflow in the README.
  • Includes IDE project metadata updates already present on the branch.

Behavior Notes

  • Prefix matching is path-component aware, so /old/user matches /old/user/.gitconfig but does not match /old/user2/.gitconfig.
  • Entries outside --from-prefix fail clearly.
  • For restore --all, outside-prefix and per-file restore failures are reported per entry, remaining entries continue restoring, and the command exits non-zero after the batch finishes.
  • For single-file restore, an outside-prefix tracked entry fails immediately with a clear error.

Tests Added

  • Command-level restore prefix remapping for single-file and --all flows.
  • Outside-prefix failure behavior for single-file and batch restore.
  • Registry immutability after remapped restore.
  • CLI coverage for remapped single-file restore, remapped batch restore, and one-sided remap flag validation.
  • StorageManager coverage for explicit destination restore with parent directory creation.

Verification

Ran locally:

cmake -S . -B build -DCFGSYNC_BUILD_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failure

Result:

100% tests passed, 0 tests failed out of 241

@olxgdm olxgdm linked an issue Jun 25, 2026 that may be closed by this pull request
@sonarqubecloud

Copy link
Copy Markdown

@olxgdm olxgdm marked this pull request as ready for review June 25, 2026 13:21
@olxgdm olxgdm merged commit 42035b2 into main Jun 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add restore prefix remapping for fresh-system restores

1 participant