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

Status constantly 'Saving 1 notes.'. #162

Closed grandfso closed 5 years ago

grandfso commented 5 years ago

Hi there, my nvPY status is constantly at: "Saving 1 notes."

The synchronization seems to be working just fine, the sync is not blocking anything. When I make a change to any note / or create a new note, the note is synced without delay, and after a while the 'Saving 1 notes.' status comes back. (During the actual sync after updating a note, the status would change to 'Saving 2 notes').

Additionaly, when I want to shut down the application, it would ask me 'Are you sure you want to exit? I'm still busy: Saving 1 notes.'.

I am running nvPY installed via apt install nvpy, so I'm running version 1.0.0. When I tried to install from git, it wouldn't run complaining about missing modules e.g. simplenote (despite simplenote was installed automatically along with the nvpy.).

yuuki0xff commented 5 years ago

Thanks bug report. I was investigating an related issue in the morning. it was probably fixed in 0dc453f265302a6837df0f6d69948d0fc48559be . Please try the fix-housekeeper-issue branch.

$ git clone https://github.com/cpbotha/nvpy
$ cd nvpy
$ git checkout origin/fix-housekeeper-issue
$ python2 -m pip install .
$ nvpy
grandfso commented 5 years ago

Hi, it seems I am unable to checkout the fix-housekeeper-issue :(

[/opt/git] $mkdir nvpy

[/opt/git] $cd nvpy/

[/opt/git/nvpy] $git clone https://github.com/cpbotha/nvpy Cloning into 'nvpy'... remote: Enumerating objects: 8, done. remote: Counting objects: 100% (8/8), done. remote: Compressing objects: 100% (8/8), done. remote: Total 2040 (delta 2), reused 2 (delta 0), pack-reused 2032 Receiving objects: 100% (2040/2040), 2.28 MiB | 3.08 MiB/s, done. Resolving deltas: 100% (1273/1273), done.

[/opt/git/nvpy] $cd nvpy/

[/opt/git/nvpy/nvpy] $git checkout origin/fix-housekeeper-issue error: pathspec 'origin/fix-housekeeper-issue' did not match any file(s) known to git

yuuki0xff commented 5 years ago

Wow sorry. I mis-typed the branch name. Please run git fetch and git checkou origin/fix-housekeeper-issuet.

grandfso commented 5 years ago

OK, so straight after launching by python -m nvpy, i get "an error occured during housekeeping. 'modifydate'".

https://i.imgur.com/WLxpS49.png

In the console it throws:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 599, in callit
    func(*args)
  File "nvpy/view.py", line 1548, in handler_housekeeper
    self.notify_observers('keep:house', None)
  File "nvpy/utils.py", line 212, in notify_observers
    o(self, evt_type, evt)
  File "nvpy/nvpy.py", line 592, in observer_view_keep_house
    nsaved = self.notes_db.save_threaded()
  File "nvpy/notes_db.py", line 568, in save_threaded
    if Note(n).need_save:
  File "nvpy/notes_db.py", line 1026, in need_save
    return float(self['modifydate']) > savedate or float(self['syncdate']) > savedate
KeyError: 'modifydate'

When I click OK on the error message, the status just says 'Starting full sync'.

yuuki0xff commented 5 years ago

Some notes are broken. I recommend you to delete the nvpy cache directory (The location is usually ~/.nvpy).

grandfso commented 5 years ago

Indeed the cache was located at path you specified. After clearing it, I DID NOT get the error message: "an error occured during housekeeping. 'modifydate'".

However, the syncing 1 note 'bug' is still there https://i.imgur.com/eR1LSAu.png

I created a brand new simplenote account and the problem does not occur at all. So it seems like this could be 'note related' bug. Is there a way to check which particular one note it is trying to sync? I have over 500+ notes there in total. I would like to keep my account and my notes ;)

yuuki0xff commented 5 years ago

Sorry late reply. I fixed a bug (f84df052f951404a7c6e92aae6b0c8378cce90af) and enabled pdb shell (ae31c4be46411b603b9cb005d5ed71538a0fb26d).

Is there a way to check which particular one note it is trying to sync?

No. but you can use other debugging approach. When an error occurred, nvpy dive into pdb interactive shell. You can check a lot of information necessary for debugging from pdb.

grandfso commented 5 years ago

Hi there, with pdb it was pretty straightforward to get the ID of the 'broken' note. After removing it from simplenote (by emptying the trash via simplenote's web interface - the note was already flagged as deleted), clearing the nvpy's cache, the sync completes and does not hang on 'Syncing 1 notes'. So seems like it is fixed.

Additional info:

$ python -m nvpy
> /opt/git/nvpy/nvpy/nvpy/notes_db.py(755)sync_full_unthreaded()
-> raise SyncError("Sync step 1 error - Could not update note {0} to server: {1}".format(key, str(uret[0])))
(Pdb) 
(Pdb) key
'db9049070f9211e59760979e943c1564'
(Pdb) str(uret[0])
'HTTP Error 412: Precondition Failed'

The note itself does not look strange, and I was able to open it from Simplenote web interface. The cached file also looks fine. I can share it with you if interested (via some private channel).

yuuki0xff commented 5 years ago

The "Precondition Failed" error sometimes occurred on my environment. It is caused by updating the same content note from local to server. I found the cause of this problem. I'll fix it.

yuuki0xff commented 5 years ago

This bug has been fixed on the 'fix-precondition-failed' branch.

yuuki0xff commented 5 years ago

Fixed bugs on 17984a163ef88465a38722cae48b42e93eec34be...b97648c64f66e54574ee87c55dcfb3aee91da792.