Skip to content
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

Merged
merged 3 commits into from
Dec 13, 2020

Conversation

aplaice
Copy link
Collaborator

@aplaice aplaice commented Nov 25, 2020

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. The deck_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 same deck_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.

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.
@ohare93
Copy link
Contributor

ohare93 commented Nov 25, 2020

Very nice work, Aplaice! 👏

crowd_anki/export/anki_exporter.py Outdated Show resolved Hide resolved
Comment on lines +76 to +77
for deck_config in deck.metadata.deck_configs.values():
self.collection.decks.save(deck_config.anki_dict)
Copy link
Owner

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?

Copy link
Collaborator Author

@aplaice aplaice Dec 12, 2020

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.

Copy link
Owner

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):
Copy link
Owner

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?

Copy link
Collaborator Author

@aplaice aplaice Dec 12, 2020

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...)

Copy link
Owner

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

@Stvad Stvad merged commit 7d13547 into Stvad:master Dec 13, 2020
@Stvad
Copy link
Owner

Stvad commented Dec 13, 2020

uploaded the new version

@aplaice
Copy link
Collaborator Author

aplaice commented Dec 13, 2020

uploaded the new version

Thanks (and thanks for reviewing/merging)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uuids can change between exports for new decks (post 2.1.26)
3 participants