-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make uuids persistent when exporting with Anki 2.1.35 (≥ 2.1.28) #110
Conversation
Fix Stvad#109. The issue is that col.decks.save() and col.models.save() now require an argument — using them without an argument has no effect.
Very nice work, Aplaice! 👏 |
for deck_config in deck.metadata.deck_configs.values(): | ||
self.collection.decks.save(deck_config.anki_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not seem right? we try to save deck config as a deck?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty weird, but it's how it seems to work, according to Anki's source. FWIW decks.save()
(without arguments) used to save both all decks and all deck configs, previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird indeed
# This saves decks and deck configurations | ||
self.collection.decks.save() | ||
self.collection.decks.flush() | ||
def _save_changes(self, deck, is_export_child=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this preserve changes to note uuid btw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean note model uuid? (If so, yes, I think so.) (Sorry, I might not have fully woken up yet, which is pretty embarrassing as it's already rather late here...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I meant actual note uid. but it seems it falls back on using the native guid, nvm :p
uploaded the new version |
Thanks (and thanks for reviewing/merging)! |
Fix #109.
The issue was that col.decks.save() and col.models.save() now require an argument — using them without an argument has no effect.
Slight issue with children
There's still a slight, partial issue related to the export of decks which have subdecks, but it seems that it was also present when exporting with Anki 2.1.26 and it only occurs for the very first export. It's a matter of a uuid being generated for the same deck config (assuming that the parent and child decks share it) when dealing with each of the parent and child decks (it's not saved in between), so phantom copies of the deck config are created in
deck.json
. Thedeck_config_uuid
that persists is the one that was last applied. After the first export, all the phantom copies are cleared out and all the (sub)decks that should share a deck config do indeed have the samedeck_config_uuid
.I'll try to fix this, as well, eventually, but since it was already previously present, it's far less urgent and I'm not sure how much time I'll have, I think that it's definitely worth merging the current PR (obviously after addressing any feedback) without a fix for this.