cpbotha / nvpy

Simplenote syncing note-taking application, inspired by Notational Velocity and ResophNotes, but uglier and cross-platformerer.
Other
849 stars 114 forks source link

Freeze when restarting nvpy before synchronization is complete #181

Closed yuuki0xff closed 5 years ago

yuuki0xff commented 5 years ago

See https://github.com/cpbotha/nvpy/issues/180#issuecomment-489398908

yuuki0xff commented 5 years ago

When offline, simplenote v2.1.2 breaks on-memory database of nvpy.

nvpy 1.2.2-dev (6ef839a5d29816df18ac5ece1e93aaf1ada37d33)

# nvpy.patch
diff --git a/nvpy/notes_db.py b/nvpy/notes_db.py
index 9d1c4a0..5fcd162 100644
--- a/nvpy/notes_db.py
+++ b/nvpy/notes_db.py
@@ -1009,7 +1009,12 @@ class NotesDB(utils.SubjectMixin):

         try:
             self.waiting_for_simplenote = True
+            print('before')
+            print(note)
             o, err = self.simplenote.update_note(note)
+            print('after')
+            print(note)
+            print('')
             self.waiting_for_simplenote = False

             if err == 0:
# stdout/stderr
$ nvpy
before
{u'modifydate': 1557121156.691686, u'tags': [], u'createdate': 1557121151.788488, u'syncdate': 0, u'content': u'new note created when offline', u'savedate': 1557129998.903475}
after
{u'tags': [], 'deleted': False, 'shareURL': '', u'syncdate': 0, 'systemTags': [], u'content': u'new note created when offline', u'savedate': 1557129998.903475, 'publishURL': '', 'modificationDate': 1557121156.691686, 'creationDate': 1557121151.788488}

ERROR: An unexpected error occurred.
... omitted ...
$ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import simplenote
>>> sn = simplenote.Simplenote('user', 'passwd')
>>> note = {'modifydate': 2.0, 'createdate': 1.0, 'tags': [], 'content': 'note'}
>>> sn.update_note(note)
(URLError(gaierror(-3, 'Temporary failure in name resolution'),), -1)
>>> note
{'tags': [], 'deleted': False, 'shareURL': '', 'systemTags': [], 'content': 'note', 'publishURL': '', 'modificationDate': 2.0, 'creationDate': 1.0}
>>>