Skip to content

UX: warn when re-initialising over existing config #5

Description

@piranhap

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:

  1. Print a warning: Already initialised (profile: default, version: 3). Use --reinit to overwrite.
  2. 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.rscmd_init()
  • src/cli.rsCommand::Init struct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingux

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions