Skip to content

Commit

Permalink
Fix: Gracefully handle invalid sync times
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RedAtman committed Aug 6, 2024
1 parent ed615aa commit 20c668a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 20c668a

Please sign in to comment.