chore: fixes and import

This commit is contained in:
xuu
2025-03-29 17:09:18 -06:00
parent 84c3099be6
commit dab5a115cf
7 changed files with 254 additions and 119 deletions
+23 -17
View File
@@ -70,6 +70,12 @@ func run(ctx context.Context, c *console.C[args]) error {
ctx, span := otel.Span(ctx)
defer span.End()
db, err := app.DB(ctx)
if err != nil {
return err
}
defer db.Close()
var inFile io.Reader
if a.baseFeed != "" {
@@ -78,30 +84,30 @@ func run(ctx context.Context, c *console.C[args]) error {
return err
}
defer f.Close()
} else {
err = storeRegistry(ctx, db, f)
if err != nil {
return err
}
}
if a.URI != "" {
res, err := http.Get(a.URI)
if err != nil {
return err
}
inFile = res.Body
defer res.Body.Close()
twtfile, err := lextwt.ParseFile(inFile, &types.Twter{
Nick: a.Nick,
URI: a.URI,
})
if err != nil {
return fmt.Errorf("%w: %w", ErrParseFailed, err)
}
return storeFeed(ctx, db, twtfile)
}
twtfile, err := lextwt.ParseFile(inFile, &types.Twter{
Nick: a.Nick,
URI: a.URI,
})
if err != nil {
return fmt.Errorf("%w: %w", ErrParseFailed, err)
}
db, err := app.DB(ctx)
if err != nil {
return err
}
defer db.Close()
return storeFeed(ctx, db, twtfile)
return nil
}(ctx)
if err != nil {
return err