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

Desktop: Fixes #7782: Markdown + Front Matter export fails when tag(s) lost #7820

Merged
merged 2 commits into from Feb 21, 2023

Conversation

pedr
Copy link
Collaborator

@pedr pedr commented Feb 21, 2023

Fixes #7782

Problem:

When the remote Tag that was associated with a Note is deleted and the client tries to synchronize, during the 'delta process' the original Tag is deleted, but the NoteTag records that are associated with it are left untouched.
When we try to export to the Markdown + Front Matter this Note would end up associated with a tag with the value undefined (because the only record that still exists is on the NoteTag table, there isn't any tag name to be used on the export) which is not supported by default by the js-yaml library.

Implementation

The best solution here would probably be to fix the synchronization process, but for now, I added a workaround for the export.

Testing

I added one test, to see the changes, you can run the test over the first commit and see the error being thrown by the third-party library.

@laurent22
Copy link
Owner

That looks good, thanks!

For information, the way sync works is that all objects are downloaded in a random order, so it might download NoteTag objects first, then later the associated Tag object. So you can't know if a Tag is missing (has been deleted) or has simply not been downloaded yet. That's why some of the code has to be designed without assuming that such or such object is going to be present.

It's also why we don't delete NoteTag when we delete a Tag - because we can't know if we've downloaded all the NoteTag from all the devices (so we'd still end up with orphan NoteTag, and a need to check for this in the code). That's the nature of Joplin being offline first which means that there's some information we can't know, but it's usually not a big problem except in some cases like this one.

We'll see maybe some day if we add a process to automatically delete unneeded NoteTags but we have to be very careful with that due to the way sync works.

@laurent22 laurent22 merged commit 6a9848e into laurent22:dev Feb 21, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2023
@pedr pedr deleted the fix-frontmatter-export branch March 10, 2023 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown + Front Matter export fails when tag(s) lost
2 participants