forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain block references on file reload
Commit fixes a bug where block references (i.e. `:block/refs` association in the db) are lost when the page containing the referenced block is re-loaded due to an update of its underlying file. Description of Bug: The bug occurs because when a file is re-loaded to the DB from disk, all existing blocks belonging to the file are deleted via `retractEntity`, and then blocks from the parsed file are added. If the file had only had small changes, the new block set will be very similar to the previous one, although with different db/ids. However, while new blocks with "id:: " properties will assume the UUID value of the previous version of the block, any references to that block via UUID will *not* be restored in the DB; they are deleted with the retractEntity command. This results in an inconsistent DB state, where references that should exist do not. Description of Fix: The 'delete-blocks-fn' passed to the graph_parser has been modified as such: - It now accepts a list of block uuids to *retain*; graph parser will pass the blocks parsed from the new file content. - For any blocks which match a UUID in the retain list, instead of deleting via retractEntity, the individual attributes are deleted via retractAttribute (the `retract-attributes` from schema.cljs is used for this purpose).
- Loading branch information
Showing
3 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters