From 4cf6da5f0a163c5a0d909a543c59dd4d96edd4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Thu, 9 Oct 2025 18:06:35 +0200 Subject: [PATCH] feat: add sync-up and sync-down --- README.md | 6 ++++++ main.py | 26 +++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9250677..e8ab258 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ Call `feather update` to synchronize all local data with the server (read items, After changing the configuration, you can call `feather regenerate` to regenerate all local files with the new configuration (to reflect the changes in the HTML template, filenames, etc.). +### Theoretical use-cases + +#### Processing with scripts + +#### Syncthing + ## Installation ### Docker diff --git a/main.py b/main.py index 9e2b390..bc254a7 100644 --- a/main.py +++ b/main.py @@ -244,12 +244,22 @@ def remove_empty_html_directories(config): if len(dirnames) == 0 and len(filenames) == 0: dirpath.rmdir() -def update(config, client_session): +def synchronize(config, client_session): # Do a full feather update mark_deleted_as_read(config, client_session) synchronize_with_server(config, client_session) remove_empty_html_directories(config) +def synchronize_local_changes(config, client_session): + # Upload local changes (read items) to the server + mark_deleted_as_read(config, client_session) + remove_empty_html_directories(config) + +def synchronize_remote_changes(config, client_session): + # Download remote changes (new items, items read from another device) from the server + synchronize_with_server(config, client_session) + remove_empty_html_directories(config) + def regenerate_files(config): for json_path in config.json_root.glob("*.json"): item_json = json.load(json_path.open("r")) @@ -269,15 +279,21 @@ def main(): description="file-based RSS reader" ) parser.add_argument( - "action", choices=("update", "regenerate"), - help='''use update to perform a full synchronization with the server; regenerate will regenerate all HTML files from the local data''' + "action", choices=("sync", "sync-up", "sync-down", "regenerate"), + help="sync: perform a full synchronization with the server; sync-up: only synchronize local changes to the server (e.g. items read locally); sync-down: only synchronize remote change from the server (e.g. new items or items read from another device); regenerate: regenerate all HTML files from the local data" ) args = parser.parse_args() config = Config() - if args.action == "update": + if args.action == "sync": client_session = ClientSession(config) - update(config, client_session) + synchronize(config, client_session) + elif args.action == "sync-up": + client_session = ClientSession(config) + synchronize_local_changes(config, client_session) + elif args.action == "sync-down": + client_session = ClientSession(config) + synchronize_remote_changes(config, client_session) elif args.action == "regenerate": regenerate_files(config)