[go: up one dir, main page]

Skip to content

mercur3/synkronizer

Repository files navigation

synkronizer

Like GNU Stow but written in Rust.

Aim

Sync config files from a git repo by using symlinks. The program tries to imitate an UNIX like directory structure:

$HOME
│
├── irrelevant-file-or-dir0
├── irrelevant-file-or-dir1
│   │
│   ├── sub0
...
│   └── subn
├── .config
│   │
│   ├── sub0
...
│   └── subn
...
│
└── irrelevant-file-or-dirn

Example:

  1. Download a repository.
  2. Run synkronizer.
  3. Resolve conflicts, if any.

Usage

Config file

  • By default searches at ./config.txt.
  • Empty lines (or lines that contain only whitespace characters) and lines that begin with # are ignored. This definition extends in this extreme case too.
  • The valid options (casing ignored) that can appear in the left hand side are:
    • HOME - which corresponds to files and directories inside ~/, except ~/.config.
    • CONFIG - which corresponds to ~/.config.
    • CONFLICT_RESOLVER - set by default as PROMP. Other possibilities include: OVERWRITE and DO_NOTHING.
  • The right hand side should have a valid path to the directory that we want to sync from.
  • A = separates both sides.

Conflict resolver

In case one instance of a config file or directory exists, the ConflictResolver enumeration is used to resolve that conflict.

  1. ConflictResolver::Prompt - is the default resolver. It prompts the user to answer if he wants to delete the current file/folder and replace it with a link to the file/folder in the repository.
  2. ConflictResolver::Overwrite - same as overwriting everything with ConflictResolver::Prompt.
  3. ConflictResolver::DoNothing - same as skipping everything with ConflictResolver::Prompt.

UI

For the moment only a command line version is supported. GTK version is in TODO.

Testing

Testing requires source code to be mounted to a certain directory and a specific directory with subdirectories to exists. Refer to test.sh for the specific locations.

Notes

  1. Files which have spaces in their name.
  2. In case when you don’t want to sync ~/ or ~/.config modify the source code and do not call App::sync_[home|config]().
  3. Config file uses DO_NOTHING to refer to libsynkronizer::sync::ConflictResolver::DoNothing.