mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
Use a transaction to refresh and create entries
Also includes few database improvements: - Speed up entries clean up with an index and a goroutine - Avoid the accumulation of enclosures for some feeds
This commit is contained in:
parent
bfb96d536e
commit
e6c6ee441a
7 changed files with 64 additions and 41 deletions
|
@ -435,12 +435,21 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
|
|||
feed.Entries[i].FeedID = feed.ID
|
||||
feed.Entries[i].UserID = feed.UserID
|
||||
|
||||
if !s.entryExists(feed.Entries[i]) {
|
||||
err := s.createEntry(feed.Entries[i])
|
||||
if err != nil {
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
return fmt.Errorf(`store: unable to start transaction: %v`, err)
|
||||
}
|
||||
|
||||
if !s.entryExists(tx, feed.Entries[i]) {
|
||||
if err := s.createEntry(tx, feed.Entries[i]); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return fmt.Errorf(`store: unable to commit transaction: %v`, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue