Summary
Running opendotsync init on a machine that is already initialised silently overwrites config.yaml, paths.yaml, and metadata.json with no warning. This destroys the local state including the parent snapshot reference, which will cause a version conflict on the next push/pull.
Reproduction
opendotsync init --backend local --path /tmp/store # first init
opendotsync push # push v1
opendotsync init --backend local --path /tmp/store # no warning — state reset
opendotsync push # version conflict or duplicate snapshot
Expected Behaviour
If a config file already exists, init should:
- Print a warning:
Already initialised (profile: default, version: 3). Use --reinit to overwrite.
- Exit with a non-zero code unless
--reinit is passed.
Proposed Fix
At the start of cmd_init (src/sync.rs), check whether config_path and metadata_path already exist. If so, print the current state and return an error unless a --reinit flag is set.
Add --reinit flag to cli::Command::Init in src/cli.rs.
Affected Files
src/sync.rs — cmd_init()
src/cli.rs — Command::Init struct
Summary
Running
opendotsync initon a machine that is already initialised silently overwritesconfig.yaml,paths.yaml, andmetadata.jsonwith no warning. This destroys the local state including the parent snapshot reference, which will cause a version conflict on the next push/pull.Reproduction
Expected Behaviour
If a config file already exists,
initshould:Already initialised (profile: default, version: 3). Use --reinit to overwrite.--reinitis passed.Proposed Fix
At the start of
cmd_init(src/sync.rs), check whetherconfig_pathandmetadata_pathalready exist. If so, print the current state and return an error unless a--reinitflag is set.Add
--reinitflag tocli::Command::Initinsrc/cli.rs.Affected Files
src/sync.rs—cmd_init()src/cli.rs—Command::Initstruct