From 124c2845e9f33229221e51e08321d9a724eba79e Mon Sep 17 00:00:00 2001 From: Radhi Fadlillah Date: Sat, 17 Feb 2018 12:30:08 +0700 Subject: [PATCH] Fix wrong mutex --- cmd/update.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/update.go b/cmd/update.go index 8835a8d..5f535b1 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -81,6 +81,7 @@ func init() { } func updateBookmarks(indices []string, url, title, excerpt string, tags []string, offline bool) ([]model.Bookmark, error) { + mutex := sync.Mutex{} // Read bookmarks from database bookmarks, err := DB.GetBookmarks(db.GetBookmarksOptions{WithContents: true}, indices...) if err != nil { @@ -97,12 +98,11 @@ func updateBookmarks(indices []string, url, title, excerpt string, tags []string // If not offline, fetch articles from internet if !offline { - mutex := sync.Mutex{} waitGroup := sync.WaitGroup{} - for i, book := range bookmarks { + waitGroup.Add(1) + go func(pos int, book model.Bookmark) { - waitGroup.Add(1) defer waitGroup.Done() article, err := readability.Parse(book.URL, 10*time.Second)