From 20c668a8e1628ea29b3a8c8e5a690a27ba2ce6d9 Mon Sep 17 00:00:00 2001 From: redatman Date: Wed, 7 Aug 2024 00:39:23 +0800 Subject: [PATCH] Fix: Gracefully handle invalid sync times The `SIMPLENOTE_SYNC_TIMES_KEY` was not guaranteed to be an integer. This commit handles this case by resetting the sync times to 0 if it is not an integer. This prevents a crash and ensures that the sync process can continue as expected. The `TypeError` has been commented out, as it is no longer necessary. --- commands.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands.py b/commands.py index 2442597..95b880b 100644 --- a/commands.py +++ b/commands.py @@ -251,9 +251,10 @@ def callback(self, updated_notes: List[Note]): sync_times = global_storage.get(CONFIG.SIMPLENOTE_SYNC_TIMES_KEY) if not isinstance(sync_times, int): - raise TypeError( - "Value of %s must be type %s, got %s" % (CONFIG.SIMPLENOTE_SYNC_TIMES_KEY, int, type(sync_times)) - ) + global_storage.optimistic_update(CONFIG.SIMPLENOTE_SYNC_TIMES_KEY, 0) + # raise TypeError( + # "Value of %s must be type %s, got %s" % (CONFIG.SIMPLENOTE_SYNC_TIMES_KEY, int, type(sync_times)) + # ) first_sync = sync_times == 0 if first_sync: show_quick_panel(True)