diff options
Diffstat (limited to 'server/cmd')
| -rw-r--r-- | server/cmd/listend/main.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/server/cmd/listend/main.go b/server/cmd/listend/main.go index e1329a9..2298db5 100644 --- a/server/cmd/listend/main.go +++ b/server/cmd/listend/main.go @@ -117,6 +117,10 @@ func main() { requests: make(chan request, 64), wakeups: make(chan struct{}, 1), } + // Wired after the worker exists, because it is the worker's own save. The pipeline runs + // for tens of minutes at a time and persists as each episode finishes, so a restart in + // the middle keeps the ones already done. + worker.words.Save = worker.save server := api.New(state, worker, api.Options{ Token: token, @@ -143,6 +147,7 @@ func main() { defer stop() if *once { + worker.words.Reclaim() worker.words.Rederive() worker.pollAll(ctx) // Recognition too, so a deployment check exercises the expensive path rather than @@ -228,6 +233,7 @@ func (w *worker) Request(feedURL, guid, enclosureURL, title string) { } func (w *worker) run(ctx context.Context, every time.Duration) { + w.words.Reclaim() w.words.Rederive() w.save() w.pollAll(ctx) @@ -373,6 +379,10 @@ func (w *worker) pollOne(ctx context.Context, feedURL string) { if fetched > 0 { log.Printf("%s: mirrored %d new episode(s)", channel.Title, fetched) } + // Before anything else looks at this show: an episode just re-mirrored may already have + // its words on disk from before its record was lost, and recognising it again would cost + // five minutes for text the server is holding. + w.words.Reclaim() w.words.Harvest(ctx, show, kept) w.words.Recurring(show) w.detect(ctx, show, kept) |
