mirror of
https://codeberg.org/Reuh/feather.git
synced 2025-10-27 18:19:32 +00:00
feat: add sync-up and sync-down
This commit is contained in:
parent
c421cf3509
commit
4cf6da5f0a
2 changed files with 27 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
26
main.py
26
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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue