1
0
Fork 0

Do not override existing entries when the crawler is enabled

This commit is contained in:
Frédéric Guillot 2018-01-20 14:04:19 -08:00
parent 208cf9892d
commit ffabb009b8
2 changed files with 7 additions and 4 deletions

View file

@ -171,7 +171,8 @@ func (h *Handler) RefreshFeed(userID, feedID int64) error {
originalFeed.EtagHeader = response.ETag
originalFeed.LastModifiedHeader = response.LastModified
if err := h.store.UpdateEntries(originalFeed.UserID, originalFeed.ID, subscription.Entries); err != nil {
// Note: We don't update existing entries when the crawler is enabled (we crawl only inexisting entries).
if err := h.store.UpdateEntries(originalFeed.UserID, originalFeed.ID, subscription.Entries, !originalFeed.Crawler); err != nil {
return err
}

View file

@ -116,15 +116,17 @@ func (s *Storage) entryExists(entry *model.Entry) bool {
return result >= 1
}
// UpdateEntries update a list of entries while refreshing a feed.
func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries) (err error) {
// UpdateEntries updates a list of entries while refreshing a feed.
func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries, updateExistingEntries bool) (err error) {
var entryHashes []string
for _, entry := range entries {
entry.UserID = userID
entry.FeedID = feedID
if s.entryExists(entry) {
if updateExistingEntries {
err = s.updateEntry(entry)
}
} else {
err = s.createEntry(entry)
}