~chrisppy/beagles-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Check for duplicate feed before adding

Details
Message ID
<20200727014133.19004-1-will.tiffany@gmail.com>
DKIM signature
missing
Download raw message
Patch: +10 -7
---
 db/db.go | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/db/db.go b/db/db.go
index eed6ac5..3872e03 100644
--- a/db/db.go
+++ b/db/db.go
@@ -130,6 +130,11 @@ func ReadDB(path string) (*Storage, error) {
// CreateFeed will collect the rss feed and process through the elements
// and add the relevant data elements to the database
func (s *Storage) CreateFeed(url string) error {
	_, ok := s.Feeds[url]
	if ok {
		return fmt.Errorf("already subscribed to feed: %s", url)
	}

	f, err := parseFeed(url)
	if err != nil {
		return fmt.Errorf("unable to fetch url: %s", err.Error())
@@ -245,18 +250,16 @@ func (s *Storage) DeleteFeed(url string) error {
		return fmt.Errorf("url was empty, unable to delete")
	}

	feed, ok := s.Feeds[url]
	if !ok {
		return fmt.Errorf("feed does not exist")
	}

	db, err := openDB(s.Path)
	if err != nil {
		return fmt.Errorf("unable to open db: %s", err.Error())
	}

	feed, ok := s.Feeds[url]
	if !ok {
		if err := db.Close(); err != nil {
			return err
		}
		return fmt.Errorf("feed does not exist")
	}
	items := feed.Items
	for _, key := range items {
		// Delete from item database
-- 
2.27.0
Details
Message ID
<C4H10UBRIP4X.LPTEMFJ9CNOK@alpha>
In-Reply-To
<20200727014133.19004-1-will.tiffany@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Thanks Will!
Reply to thread Export thread (mbox)