ig3 / anki-limitnew

Limit the number of new cards in Anki
MIT License
3 stars 0 forks source link

error when syncing (Anki 2.1.22) #4

Closed MetalFir closed 3 years ago

MetalFir commented 3 years ago

Thanks for the add-on it's a lifesaver. Unfortunately I keep getting the error below when syncing causing it to disable the add-on

Syncing failed: Traceback (most recent call last): File "aqt/sync.py", line 429, in _sync File "aqt/sync.py", line 409, in _abortingSync File "anki/sync.py", line 137, in sync File "anki/sync.py", line 219, in sanityCheck File "anki/schedv2.py", line 69, in reset File "anki/schedv2.py", line 378, in _resetNew File "anki/schedv2.py", line 375, in _resetNewCount File "anki/schedv2.py", line 209, in _walkingCount File "anki/schedv2.py", line 477, in _deckNewLimitSingle File "anki/hooks.py", line 407, in call File "/Users/xxxxxx/Library/Application Support/Anki2/addons21/anki-limitnew-master/versions/new_hook.py", line 343, in schedulerNewLimitForSingleDeck newLimit = myDeckNewLimitSingle(mw.col.sched, deck) AttributeError: 'NoneType' object has no attribute 'sched

ig3 commented 3 years ago

Thanks for letting me know. I don't have anything to sync to, so not sure how I can test a fix but I'll have a look and see what I can do.

ig3 commented 3 years ago

It seems wrong that mw.col would be NoneType but evidently that is what happened. I am suspicious that you have some other problem causing this, and you should probably find and resolve that, but I don't know the sync code: maybe it does work without a collection on the main window.

In any case, I have committed a change to detect mw.col being NoneType and avoid accessing mw.col.sched if it is. This shouldn't cause any problem for normal operation, when mw.col is not NoneType. Maybe you could try this update (you will have to install it from this repository - I haven't updated ankiweb). If it works, I'll update ankiweb.

TingTingin commented 3 years ago

i had the same problem on anki 2.1.22 and after swapping the newhook.py file it fixed it thx

ig3 commented 3 years ago

Long overdue but I'll put a new release onto ankiweb today. Totally new implementation for Anki > 2.1.26.