From 3b9f49a9c021ff8fda7a3e458e2a4272954c0f2a Mon Sep 17 00:00:00 2001 From: Felipe Marinho Date: Wed, 30 Jul 2025 14:16:06 +0000 Subject: [PATCH] chg: fix: do not cache empty results --- api/bludv.go | 5 +++++ api/comando_torrents.go | 5 +++++ api/comandohds.go | 5 +++++ api/rede_torrent.go | 5 +++++ api/starck_filmes.go | 5 +++++ api/torrent_dos_filmes.go | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/api/bludv.go b/api/bludv.go index a1ca367..fbb8c75 100644 --- a/api/bludv.go +++ b/api/bludv.go @@ -79,6 +79,11 @@ func (i *Indexer) HandlerBluDVIndexer(w http.ResponseWriter, r *http.Request) { links = append(links, link) }) + // if no links were indexed, expire the document in cache + if len(links) == 0 { + i.requester.ExpireDocument(ctx, url) + } + // extract each torrent link indexedTorrents := utils.ParallelFlatMap(links, func(link string) ([]schema.IndexedTorrent, error) { return getTorrentsBluDV(ctx, i, link) diff --git a/api/comando_torrents.go b/api/comando_torrents.go index cfae586..154b8ad 100644 --- a/api/comando_torrents.go +++ b/api/comando_torrents.go @@ -93,6 +93,11 @@ func (i *Indexer) HandlerComandoIndexer(w http.ResponseWriter, r *http.Request) links = append(links, link) }) + // if no links were indexed, expire the document in cache + if len(links) == 0 { + i.requester.ExpireDocument(ctx, url) + } + // extract each torrent link indexedTorrents := utils.ParallelFlatMap(links, func(link string) ([]schema.IndexedTorrent, error) { return getTorrents(ctx, i, link) diff --git a/api/comandohds.go b/api/comandohds.go index f20a669..30b3e2d 100644 --- a/api/comandohds.go +++ b/api/comandohds.go @@ -81,6 +81,11 @@ func (i *Indexer) HandlerComandoHDsIndexer(w http.ResponseWriter, r *http.Reques links = append(links, link) }) + // if no links were indexed, expire the document in cache + if len(links) == 0 { + i.requester.ExpireDocument(ctx, url) + } + // extract each torrent link indexedTorrents := utils.ParallelFlatMap(links, func(link string) ([]schema.IndexedTorrent, error) { return getTorrentsComandoHDs(ctx, i, link) diff --git a/api/rede_torrent.go b/api/rede_torrent.go index 1225742..0d00af8 100644 --- a/api/rede_torrent.go +++ b/api/rede_torrent.go @@ -79,6 +79,11 @@ func (i *Indexer) HandlerRedeTorrentIndexer(w http.ResponseWriter, r *http.Reque links = append(links, link) }) + // if no links were indexed, expire the document in cache + if len(links) == 0 { + i.requester.ExpireDocument(ctx, url) + } + // extract each torrent link indexedTorrents := utils.ParallelFlatMap(links, func(link string) ([]schema.IndexedTorrent, error) { return getTorrentsRedeTorrent(ctx, i, link) diff --git a/api/starck_filmes.go b/api/starck_filmes.go index 9cc5560..b699189 100644 --- a/api/starck_filmes.go +++ b/api/starck_filmes.go @@ -78,6 +78,11 @@ func (i *Indexer) HandlerStarckFilmesIndexer(w http.ResponseWriter, r *http.Requ links = append(links, link) }) + // if no links were indexed, expire the document in cache + if len(links) == 0 { + i.requester.ExpireDocument(ctx, url) + } + // extract each torrent link indexedTorrents := utils.ParallelFlatMap(links, func(link string) ([]schema.IndexedTorrent, error) { return getTorrentStarckFilmes(ctx, i, link) diff --git a/api/torrent_dos_filmes.go b/api/torrent_dos_filmes.go index 1c9d4fc..40c37c9 100644 --- a/api/torrent_dos_filmes.go +++ b/api/torrent_dos_filmes.go @@ -78,6 +78,11 @@ func (i *Indexer) HandlerTorrentDosFilmesIndexer(w http.ResponseWriter, r *http. links = append(links, link) }) + // if no links were indexed, expire the document in cache + if len(links) == 0 { + i.requester.ExpireDocument(ctx, url) + } + // extract each torrent link indexedTorrents := utils.ParallelFlatMap(links, func(link string) ([]schema.IndexedTorrent, error) { return getTorrentsTorrentDosFilmes(ctx, i, link)