Create two notes "Source.md" and "Target.md". At this point, datacore.core.datastore.links.get('Target.md') (the backlinks to Target.md) is of course empty.
In Source.md, insert a link to Target.md. At this point, the backlinks are properly populated by three objects: the note Source.md (MarkdownPage), it first section (MarkdownSection), and the first block in this section (MarkdownBlock).
Remove the link from Source.md to Targe.md. Now the problem occurs: two of the three objects are properly removed by _unindex method of Datastore, but Source.md/block1 is not. It should get back to an empty set.
MarkdownPage and MarkdownSection are linkable, so they can be properly unindexed. However, MarkdownBlock is not linkable. This is why the unindexing was skipped for Source.md/block1.
Solution
I think LINKABLE_TYPE in the first condition should instead be LINKBEARING_TYPE because we need $links here, not $link.
Steps to reproduce
datacore.core.datastore.links.get('Target.md')
(the backlinks to Target.md) is of course empty.MarkdownPage
), it first section (MarkdownSection
), and the first block in this section (MarkdownBlock
)._unindex
method ofDatastore
, butSource.md/block1
is not. It should get back to an empty set.Cause
This bug is caused by this line in
Datastore.prototype._unindex
, I think: https://github.com/blacksmithgu/datacore/blob/5fdeb17522770fa75b6a4083c6d850e83c13a6b9/src/index/datastore.ts#L215MarkdownPage
andMarkdownSection
are linkable, so they can be properly unindexed. However,MarkdownBlock
is not linkable. This is why the unindexing was skipped forSource.md/block1
.Solution
I think
LINKABLE_TYPE
in the first condition should instead beLINKBEARING_TYPE
because we need$links
here, not$link
.Result
After this modification, everything looks fine:
1.
2.
3.