chenyanming / calibredb.el

Emacs calibre client - An Ebook Management Solution in Emacs.
GNU General Public License v3.0
323 stars 17 forks source link

(wrong-type-argument char-or-string-p nil) error when the book dir is empty #76

Closed elcher closed 11 months ago

elcher commented 1 year ago

Hi,

I ran into the error of (wrong-type-argument char-or-string-p nil) when executing M-x calibredb today.

After some debugging, I found out the problem is that I have some books missing although their entries exist in the database. This causes the function calibredb-query-to-alist defined in calibredb-core.el to return nil at (:book-format ,(downcase (nth 4 spl-query-result))), which consequently leads to the bug I was referring to since downcase cannot take nil as an argument.

I have not run into this issue before so I'm not sure whether this comes from any update or something.

I think it would be nice if there is some exception handling to guard this to avoid errors coming from the inconsistencies between calibre and this package because empty book records are fine on calibre's end.

Thanks.

nrvale0 commented 12 months ago

I'm having the same problem. I started down the path of using one of the various plugins to find and purge the missing books -- not sure how they became missing in the first place! -- but even though that seems to be cleaned up I'm still getting the error. I even deleted the database and rebuilt and I'm still getting this message. Calibre itself appears to be fine.

What's really weird is that togglg-debug-on-error to active doesn't catch the error and put me anywhere where I can do some troubleshooting.

elcher commented 12 months ago

That is strange. I traced down the bug to downcase by turning on toggle-debug-on-error. I will try removing the empty book entries as you did and see whether this bug still persists.

nrvale0 commented 11 months ago

Updating mostly for posterity.

FWIW, I was unable to recover the functionality of calibredb.el interacting with Calibre even after removing all empty directories and with the newly merged PR. I instead copied all of the imported files to a temp directory, rm -rf'ed the old Calibre directory and configs, and the re-imported via dired mark and calibredb-dired-add.

All good now.