Skip to content

Commit

Permalink
fix: browser ext cannot archive and update bookmark. (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLi-CN authored Feb 5, 2023
1 parent 52d9a63 commit 47f288f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions internal/webserver/handler-api-ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,24 @@ func (h *handler) apiInsertViaExtension(w http.ResponseWriter, r *http.Request,
var contentType string
var contentBuffer io.Reader

if book.HTML == "" {
contentBuffer, contentType, _ = core.DownloadBookmark(book.URL)
if request.HTML == "" {
contentBuffer, contentType, _ = core.DownloadBookmark(request.URL)
} else {
contentType = "text/html; charset=UTF-8"
contentBuffer = bytes.NewBufferString(book.HTML)
contentBuffer = bytes.NewBufferString(request.HTML)
}

// Save the bookmark with whatever we already have downloaded
// since we need the ID in order to download the archive
books, err := h.DB.SaveBookmarks(ctx, true, request)
if err != nil {
log.Printf("error saving bookmark before downloading content: %s", err)
return
// Only when old bookmark is not exists.
if (!exist) {
books, err := h.DB.SaveBookmarks(ctx, true, request)
if err != nil {
log.Printf("error saving bookmark before downloading content: %s", err)
return
}
book = books[0]
}
book = books[0]

// At this point the web page already downloaded.
// Time to process it.
Expand Down

0 comments on commit 47f288f

Please sign in to comment.