'Edit Book' corrupts epub when find & replace fails

Bug #1275366 reported by MsBarrows
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Updated to 1.22 yesterday, today while editing some epubs to fix formatting problems/typos I've twice had it fail and error out, resulting in corruption to the epub file. As far as I can tell, it happens when I run a find and replace on something it is unable to find. For example, the second time it happened I was running a find for " </p>" (without quotes) and replacing with "</p>", in order to eliminate unnecessary spaces inserted prior to paragraph breaks. As often occurs, it took multiple passes to remove them all, so the results were something like replaced 258, 36, 1 and then on the next pass instead of reporting 0 it errored out.

The error message from that is:

calibre, version 1.22.0
ERROR: Unhandled exception: <b>TypeError</b>:QAbstractItemModel.dataChanged[QModelIndex, QModelIndex] signal has 2 argument(s) but 1 provided

calibre 1.22 [64bit] isfrozen: True is64bit: True
Windows-7-6.1.7601-SP1 Windows ('64bit', 'WindowsPE')
('Windows', '7', '6.1.7601')
Python 2.7.5
Windows: ('7', '6.1.7601', 'SP1', 'Multiprocessor Free')
Traceback (most recent call last):
  File "site-packages\calibre\gui2\tweak_book\boss.py", line 773, in search
  File "site-packages\calibre\gui2\tweak_book\boss.py", line 493, in rewind_savepoint
  File "site-packages\calibre\gui2\tweak_book\undo.py", line 119, in rewind_savepoint
TypeError: QAbstractItemModel.dataChanged[QModelIndex, QModelIndex] signal has 2 argument(s) but 1 provided

Attempts to do any further finds generates further errors. If I save the epub after the error, the epub file ends up being corrupted. Attempting to open it again gets the following error:

calibre, version 1.22.0
ERROR: Could not open ebook: D:\Calibre Library\snack_size\Revelations (648)\Revelations - snack_size.epub is not a valid EPUB file (could not find opf)

Traceback (most recent call last):
  File "site-packages\calibre\gui2\viewer\main.py", line 40, in run
  File "threading.py", line 761, in run
  File "site-packages\calibre\ebooks\oeb\iterator\book.py", line 99, in __enter__
  File "site-packages\calibre\customize\conversion.py", line 241, in __call__
  File "site-packages\calibre\ebooks\conversion\plugins\epub_input.py", line 200, in convert
ValueError: D:\Calibre Library\snack_size\Revelations (648)\Revelations - snack_size.epub is not a valid EPUB file (could not find opf)

Revision history for this message
MsBarrows (msbarrows) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: New → 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.