diff options
author | siddharth <s@ricketyspace.net> | 2021-11-28 17:55:37 -0500 |
---|---|---|
committer | siddharth <s@ricketyspace.net> | 2021-11-28 17:55:37 -0500 |
commit | 0206d6e63427c168fe6f0fcdf2bee17e964a3d65 (patch) | |
tree | 39b4c42dbeda627d225a95b77db636dbc61b09b6 /db/db.go | |
parent | 0ee116a416bf1868ed6ed3e7c040b24e13fdb549 (diff) |
db: add FernDB.Add
Diffstat (limited to 'db/db.go')
-rw-r--r-- | db/db.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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() +} |