1
0
Fork 1
mirror of https://github.com/0x2E/fusion.git synced 2025-06-08 13:37:11 +09:00

Merge pull request #70 from mtlynch/simplify-failure

Get rid of failure variable in Puller.do
This commit is contained in:
Yuan 2025-03-10 13:05:36 +08:00 committed by GitHub
commit e5a53a1ea3
Signed by: github
GPG key ID: B5690EEEBB952194

View file

@ -9,6 +9,7 @@ import (
"github.com/0x2e/fusion/model" "github.com/0x2e/fusion/model"
"github.com/0x2e/fusion/pkg/httpx" "github.com/0x2e/fusion/pkg/httpx"
"github.com/0x2e/fusion/pkg/ptr"
"github.com/mmcdole/gofeed" "github.com/mmcdole/gofeed"
) )
@ -35,11 +36,9 @@ func (p *Puller) do(ctx context.Context, f *model.Feed, force bool) error {
} }
} }
failure := ""
fetched, err := FetchFeed(ctx, f) fetched, err := FetchFeed(ctx, f)
if err != nil { if err != nil {
failure = err.Error() p.feedRepo.Update(f.ID, &model.Feed{Failure: ptr.To(err.Error())})
p.feedRepo.Update(f.ID, &model.Feed{Failure: &failure})
return err return err
} }
if fetched == nil { if fetched == nil {
@ -76,7 +75,7 @@ func (p *Puller) do(ctx context.Context, f *model.Feed, force bool) error {
logger.Infof("fetched %d items", len(fetched.Items)) logger.Infof("fetched %d items", len(fetched.Items))
return p.feedRepo.Update(f.ID, &model.Feed{ return p.feedRepo.Update(f.ID, &model.Feed{
LastBuild: fetched.PublishedParsed, LastBuild: fetched.PublishedParsed,
Failure: &failure, Failure: ptr.To(""),
}) })
} }