Skip to content

Commit

Permalink
Fixed an issue which caused crash after sending individual HN item to…
Browse files Browse the repository at this point in the history
… Kindle.
  • Loading branch information
abishekmuthian committed Apr 18, 2022
1 parent 0653dda commit f50ea5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ hntoebook_linux_amd64.zip
hntoebook_linux_arm64.zip
hntoebook_windows_amd64.zip
db
models
models
test
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func OperationsMode(db *badger.DB, mode string) {
item, err := txn.Get([]byte("mobiPath"))

if err != nil {
log.Fatalln("Error accessing db for mobiPath, Did you set the config using -c?", err)
log.Fatalln("Error accessing mobiPath, Did you set the config using -c?ing db for mobiPath, Did you set the config using -c?", err)
} else {

err := item.Value(func(val []byte) error {
Expand Down Expand Up @@ -300,5 +300,5 @@ func main() {
OperationsMode(db, "default")
}

db.Close()
defer db.Close()
}
5 changes: 4 additions & 1 deletion stories/operations/mobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ func PDFToMobiGenerator(db *badger.DB, story *stories.Story, storyItem *hnapi.St
fmt.Println(output)

err = db.Update(func(txn *badger.Txn) error {
err := txn.Set([]byte(strconv.Itoa(story.Id)), []byte("true"))
var err error
if story != nil {
err = txn.Set([]byte(strconv.Itoa(story.Id)), []byte("true"))
}
return err
})
if err != nil {
Expand Down

0 comments on commit f50ea5c

Please sign in to comment.