Rescrape all links if needed on startup

This commit is contained in:
2025-05-02 19:51:41 +09:30
parent ae654998f7
commit 0171be0ee4
3 changed files with 39 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ func main() {
}
dbh := db.DB{}
err := dbh.Open(dbPath)
rescrape, err := dbh.Open(dbPath)
if err != nil {
log.Fatal(err)
}
@@ -52,5 +52,19 @@ func main() {
server := web.Create(bmm, cmm)
go bmm.RunQueue()
go bmm.UpdateContent()
if rescrape {
log.Printf("queueing all bookmarks for rescraping, as index was just created")
bookmarks, err := bmm.AllBookmarks()
if err != nil {
log.Printf("could not load all bookmarks: %s", err.Error())
} else {
for _, bm := range bookmarks {
bmm.QueueScrape(&bm)
}
}
log.Printf("queued %d bookmarks for scraping", len(bookmarks))
}
server.Start()
}