Incorrectly formed file names written to device in 2.5.1

Bug #1496737 reported by jake
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Kobo Touch Extended Driver
Fix Released
Low
Joel Goguen

Bug Description

Using the KoboTouchExtended driver v. 2.5.1 to write kepubs to device results in unexpected file names.
My naming template is "{author_sort}/{series}/{title}", so for example, file name for "War and Peace" by Leo Tolstoy should end up being "War and Peace.kepub.epub".
Instead, it is written as "War and Peac.kepub.epub".

The cause is introduced in commit https://github.com/jgoguen/calibre-kobo-driver/commit/64bfebde4e6f7231e9a497736ad8b9c8a291aeed or specifically the line number 303 in device/driver.py.

The line is:
path = path.rstrip(EPUB_EXT) + KEPUB_EXT + EPUB_EXT

Problem being the rstrip function used to strip the EPUB_EXT extension (ie. '.epub') as rstrip strips all listed characters from the end of the string and not the substring as probably intended.

So for string like 'Deep.epub' rstrip('.epub') would produce 'D'.

Joel Goguen (jgoguen)
Changed in calibre-kobo-driver:
status: New → Triaged
importance: Undecided → Low
assignee: nobody → Joel Goguen (jgoguen)
Revision history for this message
Joel Goguen (jgoguen) wrote :

Ahh, misuse of str.rstrip(). Since names that aren't UUIDs are purely for convenience (Kobo drops KePubs as $UUID.kepub.epub) this isn't all that important. The biggest problem is name collisions if a name ends with a combination of the characters '.epub', which isn't too likely I don't think. Will get to this when I have a few minutes, looks like using str.replace() instead should fix this. Might even announce a new major version that does it more like Kobo and forces using UUID names.

Revision history for this message
jake (nichiren) wrote :

Indeed, this is not a big issue.
Only reason I even noticed this is that I had to perform a factory reset, then I restored an earlier backup of the database and uploaded the books back using Calibre. Incidentally the book I was currently reading at the moment was affected and Kobo couldn't find it, along with number of other books in collections.

Of course, if you were to change the driver to use UUID names, the same thing would happen. So, might I suggest make it default behaviour but possible to disable and revert to 'legacy' behaviour via driver options?

Joel Goguen (jgoguen)
Changed in calibre-kobo-driver:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.