1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Improve entry existance check to make better use of index

This commit is contained in:
Frédéric Guillot 2023-06-24 12:56:53 -07:00
parent b552c293ca
commit aadbd5adf3
2 changed files with 34 additions and 12 deletions

View file

@ -286,9 +286,19 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
return fmt.Errorf(`store: unable to start transaction: %v`, err)
}
if !s.entryExists(tx, feed.Entries[i]) {
entryExists, err := s.entryExists(tx, feed.Entries[i])
if err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
return fmt.Errorf(`store: unable to rollback transaction: %v (rolled back due to: %v)`, rollbackErr, err)
}
return err
}
if !entryExists {
if err := s.createEntry(tx, feed.Entries[i]); err != nil {
tx.Rollback()
if rollbackErr := tx.Rollback(); rollbackErr != nil {
return fmt.Errorf(`store: unable to rollback transaction: %v (rolled back due to: %v)`, rollbackErr, err)
}
return err
}
}