1
0
Fork 0
mirror of https://codeberg.org/Reuh/feather.git synced 2025-10-27 10:09:32 +00:00

fix: mark-as-read articles that were read on the server when only_sync_unread_articles = true

This commit is contained in:
Étienne Fildadut 2025-10-18 15:39:28 +02:00
parent d77a92cb82
commit 0db9881d09

View file

@ -160,20 +160,26 @@ class FeatherApp:
article.write() article.write()
updated_articles += 1 updated_articles += 1
# Remove articles that we didn't get from the server but are in the JSON directory # Remove or mark-as-read articles that we didn't get from the server but are in the JSON directory
removed_articles = 0 removed_articles = 0
article_cutoff_timestamp = ( article_cutoff_timestamp = (
datetime.now().timestamp() - config.keep_read_articles_for datetime.now().timestamp() - config.keep_read_articles_for
) )
for article in self.iter_articles(): for article in self.iter_articles():
if ( if article.id not in grabbed_article_paths:
# we sync all articles: remove all articles that aren't on the server # we only sync unread: articles we didn't get from the server were read or purged
not config.only_sync_unread_articles if config.only_sync_unread_articles:
# we only sync unread: only remove articles that are too old if article.last_write < article_cutoff_timestamp:
or article.last_write < article_cutoff_timestamp article.delete()
) and article.id not in grabbed_article_paths: removed_articles += 1
article.delete() elif article.unread:
removed_articles += 1 article.unread = False
article.regenerate()
updated_articles += 1
# we sync all articles: articles we didn't get from the server were purged
else:
article.delete()
removed_articles += 1
print( print(
f"Synchronization successful ({new_articles} new articles, {updated_articles} updated, {removed_articles} removed)" f"Synchronization successful ({new_articles} new articles, {updated_articles} updated, {removed_articles} removed)"