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

feat: only connect to server when necessary in sync-up

This commit is contained in:
Étienne Fildadut 2025-10-13 14:32:35 +02:00
parent eee54c948c
commit a0563db7d4

View file

@ -19,6 +19,9 @@ class FeatherApp:
if not self._client_session: if not self._client_session:
config = self.config config = self.config
api = config.server_api api = config.server_api
print(
f"Connecting to {config.server_user}@{config.server_url} ({api} API)..."
)
if api == "googlereader": if api == "googlereader":
self._client_session = GReaderSession(config) self._client_session = GReaderSession(config)
elif api == "ttrss": elif api == "ttrss":
@ -57,7 +60,6 @@ class FeatherApp:
def toggle_read_flag_for_deleted(self): def toggle_read_flag_for_deleted(self):
"""Mark articles that are in the JSON directory but with missing HTML file as read/unread on the server""" """Mark articles that are in the JSON directory but with missing HTML file as read/unread on the server"""
config = self.config config = self.config
client_session = self.get_client_session()
# gather articles to mark as read/unread # gather articles to mark as read/unread
marked_as_read, marked_as_unread = 0, 0 marked_as_read, marked_as_unread = 0, 0
@ -72,7 +74,11 @@ class FeatherApp:
to_mark_as_unread.append(article) to_mark_as_unread.append(article)
marked_as_unread += 1 marked_as_unread += 1
if len(to_mark_as_read) == len(to_mark_as_unread) == 0:
return # nothing to do
# change read state on server # change read state on server
client_session = self.get_client_session()
to_mark_as_read_id = [article.id for article in to_mark_as_read] to_mark_as_read_id = [article.id for article in to_mark_as_read]
for i in range(0, len(to_mark_as_read_id), config.articles_per_query): for i in range(0, len(to_mark_as_read_id), config.articles_per_query):
client_session.set_read_flag( client_session.set_read_flag(
@ -102,7 +108,7 @@ class FeatherApp:
config = self.config config = self.config
client_session = self.get_client_session() client_session = self.get_client_session()
print("Synchronizing with server...") print("Synchronizing from server...")
new_articles, updated_articles = 0, 0 new_articles, updated_articles = 0, 0
grabbed_article_paths: set[ArticleId] = set() grabbed_article_paths: set[ArticleId] = set()