Commit Graph

58 Commits

Author SHA1 Message Date
9fd70deb9d gitignore : add dist folder
The dist folder is created when running poetry build ignore it.
2026-01-23 19:53:00 +01:00
dd042910a9 synchroniser : update_links : use run instead of Popen
using Popen causes the command to return before making the connection so
the closing of the master connection (in runners) happens before we had
time to log into the server forcing us to complete an extra login step.
2026-01-23 17:33:41 +01:00
fd825f7e87 synchroniser : use -S to avoid login in
We create a master ssh connection the -S flag uses this to avoid having
to log in again.
2026-01-23 17:29:40 +01:00
c7f0a67f17 runners : add synchronisation to unisync_add
unisync_add was missing synchronisation steps that allow to
synchronise a new file (present on the server but as a link locally).
This adds the two necessary synchronisations, the first one so all the
files are up to date and are not overwritten by the second one which
forces all the changes from the remote to overwrite the local ones. This
has the effect to replace the link with the actual file.
2026-01-21 10:33:52 +01:00
23a661107e Merge branch 'backup' into dev
Adds the possibility to use the backup function of unison
2026-01-20 10:59:47 +01:00
cf508eb94c main : pass the backup options to the synchroniser 2026-01-20 10:48:44 +01:00
5ec43f9166 synchroniser : move backup options to init
Moves the backup options from sync_files to init.
The options are needed in links (to ignore the backup folders)
so it is way easier to have them as attributes.
To do this we move everything related to backup into __init__.
Also remove the option from the runner.
2026-01-20 10:33:13 +01:00
cf49ffb8e8 synchroniser : fix broken synchronisation
Append was used instead of extend which made a list inside of a list
instead of appending the content at the end fix that.
Convert backup.maxbackups to str as needed for subprocess.
2026-01-09 18:31:00 +01:00
c34d30a006 defaults : switch prefix and suffix
I mixed up the prefix and suffix, fix that
2026-01-08 14:19:03 +01:00
bb05990464 runners : pass config.backup to sync_files
After adding the backup infrastructure to config and synchroniser the
only thing left to do is pass the BackupConfig to sync_files.
2026-01-08 14:13:14 +01:00
aaa4a8f12c runners : delete unused arguments
Use the del keyword for unused functions arguments in runners.
All the runners must have the same signature however some do not use
all of the provided arguments so we delete them so the developement
tools do not generate warnings.
2026-01-08 14:06:36 +01:00
56da79f124 runners, main : pass the config to the runners
Some of the runners need the configuration to perform their task.
So pass it to all of them and edit the call in main to reflect this
change.
2026-01-08 14:04:05 +01:00
0e8d568fea main : Use pathlib instead of os.path
Removes every use of os.path and replaces it with the equivalent pathlib
method.
Allows to avoid importing os.
2026-01-08 13:46:01 +01:00
2ae9c38627 tests : add some simple code to run a few tests 2026-01-07 23:35:26 +01:00
667c418f09 synchroniser : add backup to sync_files
Adds the option to enable backup when synchronising.
This is done in sync_files by passing the appropriate arguments to sync.
For this we need to add an argument to sync_files as the backup
configuration options are needed.
The configuration options are imported from unisync.config.BackupConfig.
Also import typing.cast to be able to narrow down a type.
2026-01-07 23:32:24 +01:00
f618932584 synchroniser : add arbitrary synchronisation arguments
Add the option to give arbitrary arguments to the unison call.
These arguments must be passed as a list to sync and will be given to
unison as is.
This is a prerequisite for using the backup system of unison as the
arguments for backup will only be given when synchronising the files and
not the links.
2026-01-07 23:27:48 +01:00
f5e455fc79 config, defaults: add configuration for backups
Add configuration options for creating backups during the
synchronisation.
2026-01-05 17:17:41 +01:00
78a4d9df36 gitignore : ignore docs/build
The docs will be added later but to prevent the mess when switching
between branches ignore the build folder.
2026-01-04 19:22:04 +01:00
7dd7b57e1f synchroniser : Use a consistent docstring format.
Edit the docstrings so they use a consistent format.
Also add a short module docstring.
2026-01-04 14:31:16 +01:00
b10ed69d59 defaults : change type of MISC_CACHE_DIR_PATH to str
DEFAULT_MISC_CACHE_DIR_PATH was a Path but the fallbacks of config.get
in config.py will be converted to a string so make it a string instead
and do the conversion later
2026-01-04 12:22:21 +01:00
ec8030fc81 config : fix cache_dir_path value parsing error
Configparser's config.get returns a string and we want a Path. for the
moment convert it to Path directly.
2026-01-03 18:05:43 +01:00
f050dcc94f runners : fix sync runner not synchronising links
The wrong function was call in the sync runner (update_links instead of
sync_links) which mean the links were updated remotly but never
synchronised with the local.
Call sync_links instead.
We keep the call to update_links but set it to be in background.
2026-01-03 18:02:20 +01:00
f40a5c9276 Merge branch 'abstract_defaults'
Abstract the defaults into a seperate file
2026-01-03 17:20:18 +01:00
0e80ba0b0d config : use the defaults from defaults.py
Remove the defaults from the dataclasses as they are redundent with the
fallbacks of configparser.
Use the values in defaults.py as the fallbacks instead of hardcoded
values.
2026-01-03 17:18:19 +01:00
a223f04909 config : take cache_dir_path into account
cache_dir_path and all of the OtherConfig was ignored and the default
value was loaded, read its value from the config file instead.
2026-01-03 17:15:22 +01:00
e42ae71862 defaults : Create defaults.py
Creates the file defaults.py this is used to store the defaults and
easily include them into the config.
Changing defaults is thus possible without touching the code leaving
less room for errors.
2026-01-03 17:10:06 +01:00
58c7f7d1be Add main as a script with poetry 2026-01-03 16:39:00 +01:00
eefb21faff Mark local imports as such.
Prefix local imports with "unisync." so they are not mistaken with
external modules imports
2026-01-03 16:24:58 +01:00
941c467fc2 Bump copyright year and add missing file headers 2026-01-02 10:58:27 +01:00
4dcab777ca Merge branch 'dev'
Got to a state that seems stable enough to go into main
2026-01-02 10:45:00 +01:00
a169890351 main : adds subcommands, move to Path and improve
Multiple changes to the main file, after this unisync becomes kind of
usable.
Add subcommands : this uses the 2 previous commits to add the
subcommands to unisync it is now possible to sync, add and mount.
pathlib : move from PosixPath to Path
Remove unused imports
Rename base_namespace to cli_args
Add some comments and TODOs
2026-01-02 10:44:59 +01:00
b70070ba1a argparser : adds subcommands to the argparser
this adds subcommands to the argparser using subparsers, we also set a
default value for func depending on which of the subcommands is
selected.
Also change the formatting of the epilog so it is on two lines.
2026-01-02 10:44:58 +01:00
bd72d740e6 runners : Create runners file and basic runnners
This adds runners.py, it contains a set of functions that peform all the
various task that unisync can do (sync, add and mount for now).
They are simple function that put together all the rest.
2026-01-02 10:44:57 +01:00
e43c16adb3 paths : fixes write_new_paths writing of the file
I was writing the file using 'w' instead of 'a' so the old paths were
deleted use 'a'.
2026-01-02 10:44:56 +01:00
10200fceb9 config : fallback to port 22 instead of None
The configparser fallback option for port was None set it to use 22
instead as None doesn't make sense
2026-01-02 10:44:55 +01:00
27924013d9 Bug fixes and small improvements
Fix :
- paths : true instead of True
- paths : Path has no len convert to str first to get the number of
  characters

Improvements :
- Replace all PosixPath by Path
2026-01-01 17:24:46 +01:00
138bc6d24a Update README to reflect the state of the project 2025-12-31 00:04:53 +01:00
48179034a7 Adds prerequisites to README 2025-12-31 00:03:59 +01:00
f9001ecb9d Adds usage of the paths manager 2025-12-31 00:03:17 +01:00
86a6c8acce Adds error handling for the paths 2025-12-30 17:56:03 +01:00
4f6f48247d Add classes for error handling 2025-12-30 17:54:47 +01:00
8caba75060 Adds paths adding functionnality
Adds functions that allows adding new paths to the synchronisation.
When writing the new paths to the file if a parent directory is
synchronised all the childrens are removed.
2025-08-10 18:21:10 +02:00
b35391f1f9 Adds an Other category to the config
This creates a new optionnal category in the config called other that is
used to configure various aspects of unison.
Currently it only allows to customise the path to the cache directory
which is ~/.unisync by default
2025-07-31 11:47:44 +02:00
c5992ef19e Adds get_paths_to_sync and organise it in a class
This refactors the paths functions in a class called PathsManager
allowing to share some data like the Paths to the various directories
unisync works with.
This commit also creates the get_paths_to_sync method which simply reads
the paths file and returns its content as a list
2025-07-31 11:45:17 +02:00
837cc1bcf4 Adds mount_remote_dir
Adds the mount_remote_dir method to the synchroniser, this allows to
mount the remote directory in order to access it with the generated
links.
Also adds the background parameter to the documentation of update_links
2025-07-28 15:31:40 +02:00
87db8a0498 Adds links generation and update
Adds update_links to the synchroniser which updates the links.
It should also be able to generate links on the first run.
2025-07-27 17:46:37 +02:00
11513adf48 Improves user_select_files documentation 2025-07-25 12:02:25 +02:00
aaa4ef61d5 Adds beginning of paths management
The paths file will be used for everything related to the paths to
synchronise.
Adds the user_select_files functions that allows the user to select
paths
2025-07-24 15:59:42 +02:00
fec09b6d0b Adds comments to the dataclasses in config 2025-07-24 15:48:13 +02:00
2566458e25 Complete README 2025-07-11 23:21:41 +02:00