Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit 09a7655

Browse files
committed
workaround total note count evernote bug
Evernote api can return a total note count that is 16 greater than the actual length of the list of available notes. So, rather than taking total notes as a target in the fetching loop, we also look to see if the retrieved notes length is zero, at which point we presume there will be no further notes.
1 parent 53a1425 commit 09a7655

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

geeknote/geeknote.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ def findNotes(
303303
)
304304

305305
# Reduces the count by the amount of notes already retrieved
306-
count = max(count - len(result.notes), 0)
306+
# In none are initially retrieved, presume no more exist to retrieve
307+
if result.notes:
308+
count = max(count - len(result.notes), 0)
309+
else:
310+
count = 0
307311

308312
# Evernote api will only return so many notes in one go. Checks for more
309313
# notes to come whilst obeying count rules
@@ -312,8 +316,11 @@ def findNotes(
312316
newresult = self.getNoteStore().findNotesMetadata(
313317
self.authToken, noteFilter, offset, count, meta
314318
)
315-
result.notes += newresult.notes
316-
count = max(count - len(newresult.notes), 0)
319+
if newresult.notes:
320+
result.notes += newresult.notes
321+
count = max(count - len(newresult.notes), 0)
322+
else:
323+
count = 0
317324

318325
return result
319326

0 commit comments

Comments
 (0)