Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: browser ext cannot archive and update bookmark. #560

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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