mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-12-03 15:18:06 +00:00
Implement the rocket link migration algorithm
This commit is contained in:
@@ -41,7 +41,7 @@ var backlinkIndex = make(map[string]linkSet)
|
||||
// IndexBacklinks traverses all text hyphae, extracts links from them and forms an initial index. Call it when indexing and reindexing hyphae.
|
||||
func IndexBacklinks() {
|
||||
// It is safe to ignore the mutex, because there is only one worker.
|
||||
for h := range hyphae.FilterTextHyphae(hyphae.YieldExistingHyphae()) {
|
||||
for h := range hyphae.FilterHyphaeWithText(hyphae.YieldExistingHyphae()) {
|
||||
foundLinks := extractHyphaLinksFromContent(h.Name, fetchText(h))
|
||||
for _, link := range foundLinks {
|
||||
if _, exists := backlinkIndex[link]; !exists {
|
||||
|
||||
@@ -21,8 +21,9 @@ func YieldExistingHyphae() chan *Hypha {
|
||||
return ch
|
||||
}
|
||||
|
||||
// FilterTextHyphae filters the source channel and yields only those hyphae than have text parts.
|
||||
func FilterTextHyphae(src chan *Hypha) chan *Hypha {
|
||||
// FilterHyphaeWithText filters the source channel and yields only those hyphae than have text parts.
|
||||
func FilterHyphaeWithText(src chan *Hypha) chan *Hypha {
|
||||
// TODO: reimplement as a function with a callback?
|
||||
sink := make(chan *Hypha)
|
||||
go func() {
|
||||
for h := range src {
|
||||
|
||||
Reference in New Issue
Block a user