summaryrefslogtreecommitdiffstats
path: root/db/db.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-11-28 17:55:37 -0500
committersiddharth <s@ricketyspace.net>2021-11-28 17:55:37 -0500
commit0206d6e63427c168fe6f0fcdf2bee17e964a3d65 (patch)
tree39b4c42dbeda627d225a95b77db636dbc61b09b6 /db/db.go
parent0ee116a416bf1868ed6ed3e7c040b24e13fdb549 (diff)
db: add FernDB.Add
Diffstat (limited to 'db/db.go')
-rw-r--r--db/db.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/db/db.go b/db/db.go
index 6dfda22..bbe5b36 100644
--- a/db/db.go
+++ b/db/db.go
@@ -82,3 +82,17 @@ func (fdb *FernDB) Exists(feed, entry string) bool {
}
+func (fdb *FernDB) Add(feed, entry string) {
+ // Check if entry already exist for feed.
+ if fdb.Exists(feed, entry) {
+ return
+ }
+
+ // Add entry.
+ fdb.mutex.Lock()
+ if _, ok := fdb.downloaded[feed]; !ok {
+ fdb.downloaded[feed] = make([]string, 0)
+ }
+ fdb.downloaded[feed] = append(fdb.downloaded[feed], entry)
+ fdb.mutex.Unlock()
+}