aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage/entry.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-09-18 22:41:33 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-09-18 22:53:47 -0700
commitd610d091fed6dbac3a7ae7e6a67e6e8455b77755 (patch)
tree8e410a7c865fe73ec1e7d9b8c6118eaee2970752 /storage/entry.go
parent36d773223481dd42d31499b3ea73e6999ff9f58e (diff)
Avoid constraint error when having duplicate entries
During feed creation, duplicated entries will generate an SQL contraint error. This change ignore the duplicated entry to avoid showing an error.
Diffstat (limited to 'storage/entry.go')
-rw-r--r--storage/entry.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/storage/entry.go b/storage/entry.go
index d3d16bb..f36bcbe 100644
--- a/storage/entry.go
+++ b/storage/entry.go
@@ -84,7 +84,7 @@ func (s *Storage) createEntry(entry *model.Entry) error {
).Scan(&entry.ID, &entry.Status)
if err != nil {
- return fmt.Errorf("unable to create entry %q (feed #%d): %v", entry.URL, entry.FeedID, err)
+ return fmt.Errorf("Unable to create entry %q (feed #%d): %v", entry.URL, entry.FeedID, err)
}
for i := 0; i < len(entry.Enclosures); i++ {
@@ -137,9 +137,9 @@ func (s *Storage) updateEntry(entry *model.Entry) error {
// entryExists checks if an entry already exists based on its hash when refreshing a feed.
func (s *Storage) entryExists(entry *model.Entry) bool {
var result int
- query := `SELECT count(*) as c FROM entries WHERE user_id=$1 AND feed_id=$2 AND hash=$3`
+ query := `SELECT 1 FROM entries WHERE user_id=$1 AND feed_id=$2 AND hash=$3`
s.db.QueryRow(query, entry.UserID, entry.FeedID, entry.Hash).Scan(&result)
- return result >= 1
+ return result == 1
}
// cleanupEntries deletes from the database entries marked as "removed" and not visible anymore in the feed.