diff --git a/internal/webserver/handler-api-ext.go b/internal/webserver/handler-api-ext.go index ba08abdc3..67994ab46 100644 --- a/internal/webserver/handler-api-ext.go +++ b/internal/webserver/handler-api-ext.go @@ -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.