84 Commits

Author SHA1 Message Date
ae0beac9e0 Catch UnknownSSHError and do not use return codes
The runners were still checking for the return codes of
create_ssh_master_connection instead of catching the exception.
We now catch the exceptions we calling the runners in main.
2026-01-31 12:30:47 +01:00
072c2a26e6 errors : Add program ending function
Add a function that quits the program using sys.exit.
This is useful when we enconter a fatal error.
2026-01-31 11:57:09 +01:00
b0c165b8b0 Revert "paths : make TimeoutExpired handling clearer"
This reverts commit 041ede22e1.

There is no point in using "as e" and "raise e", the original version was
better.
2026-01-31 11:56:51 +01:00
6b8686351a defaults : Capitalize the c of Copyright 2026-01-30 19:12:37 +01:00
dcca9c5167 Merge branch 'errors' into dev
Raise Exceptions instead of using return codes
2026-01-30 17:43:01 +01:00
041ede22e1 paths : make TimeoutExpired handling clearer 2026-01-30 17:41:53 +01:00
adfded92d0 synchroniser : raise error instead of returning a value
Raise a FatalSyncError when the synchronisation fails instead of
returning the unison return code.
2026-01-30 17:40:41 +01:00
7fae1b154a errors : Derive Errors from Exception
According to the docs user defined Exceptions should derive from
Exception not BaseException.
2026-01-30 17:39:28 +01:00
3dbd7fc445 doc : remove extra whitespace 2026-01-30 17:14:35 +01:00
10a79554d3 synchroniser : use prefer instead of force
When doing a forced synchronisation use the prefer directive instead of
force. This makes unison choose the remote version in case of conflicts
only and not for every change. This allows the add subcommand to be used
for adding a file to the sync (that is already present remotly) as well
as adding a brand new file from the local machine (after creating it or
downloading from somewhere for example).
2026-01-30 17:06:55 +01:00
f2b676043c Merge branch 'linter' into dev
Add pylint to the project and fix some of its reports.
2026-01-30 15:31:33 +01:00
24bc6bcc94 Merge branch 'doc' into dev
This adds documentation options using sphinx.
The doc still mostly needs to be written
2026-01-30 15:29:15 +01:00
7dd01260b3 runners : linter reports cleanup
del an unused parameter and remove a whitespace
2026-01-30 15:19:46 +01:00
2dafcc8c6b paths : linter reports cleanup
use [] instead of list()
2026-01-28 18:22:37 +01:00
cbfbb32b86 main : linter reports cleanup
use is not None instead of != None and remove a useless pass
2026-01-28 18:21:38 +01:00
942b6c3cef main : import PathsManager instead of * 2026-01-28 18:21:13 +01:00
a281fab8db defaults : remove trailing whitespace 2026-01-28 16:21:30 +01:00
033de7e7ca config : cleanup linter warnings 2026-01-28 16:20:40 +01:00
405e978796 config : reraise exception instead of raising a new one 2026-01-28 16:19:30 +01:00
68c03c18d5 config : remove unused import 2026-01-28 16:19:06 +01:00
d0cd6353d7 pyproject.toml : Add pylint as dev dependency 2026-01-28 16:14:25 +01:00
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
7705731dd5 docs : add explanation of what is unisync
also add an example
2026-01-20 23:39:48 +01:00
a922eaa542 synchroniser : use exception instead of return codes
In create_ssh_master_connection return codes where used instead of
proper error handling with exception, replace these codes with the
raising of an appropriate exception.
2026-01-20 22:23:09 +01:00
8836a0120b errors : adds UnknownSSHError
This error is used to report that an unknown error happened during an
invocation of ssh.
2026-01-20 22:22:00 +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
e639c12c20 docs : Add sphinx for handling documentation
Edit gitignore by ignoring the docs/build directory
Add sphinx dependencies to pyproject
Add docs folder
2026-01-04 19:18:57 +01:00
c10077392e Change TODOs format.
Use TODO: instead of TODO
2026-01-04 19:18:18 +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