Epub corrupted after editing

Bug #1627558 reported by Rachmiel Langer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Expired
Undecided
Unassigned

Bug Description

After editing an epub through the Calibre editor (& accessing the book fine), at some point after making additional edits & saving the book with no reported problem, the book is no longer accessible. This is after editing about 100 index split html files. Is there any way to recover the edited book?

This is under Calibre version 2.67 (64 bit),
Windows 7 Home Premium, service pack 1

The following error shows when trying to edit the book again,

Failed to open book

Details show:

calibre, version 2.67.0
ERROR: Failed to open book: Failed to open book, click Show details for more information.

Traceback (most recent call last):
  File "site-packages\calibre\gui2\tweak_book\job.py", line 34, in run
  File "site-packages\calibre\gui2\tweak_book\boss.py", line 57, in get_container
  File "site-packages\calibre\ebooks\oeb\polish\container.py", line 1418, in get_container
  File "site-packages\calibre\ebooks\oeb\polish\container.py", line 1084, in __init__
InvalidEpub: No META-INF/container.xml in epub

---------------

Just trying to read it read yields:

Failed to read book

Details shows:

calibre, version 2.67.0
ERROR: Could not open ebook: Failed to read book, D:\My Documents\Calibre Library\R Hayim H. Donin\To Be A Jew_ A Guide To Jewish Obse (616)\To Be A Jew_ A Guide To Jewish - R Hayim H. Donin.epub click "Show Details" for more information

Traceback (most recent call last):
  File "site-packages\calibre\utils\ipc\simple_worker.py", line 276, in main
  File "site-packages\calibre\ebooks\oeb\iterator\book.py", line 62, in extract_book
  File "site-packages\calibre\customize\conversion.py", line 241, in __call__
  File "site-packages\calibre\ebooks\conversion\plugins\epub_input.py", line 246, in convert
ValueError: D:\My Documents\Calibre Library\R Hayim H. Donin\To Be A Jew_ A Guide To Jewish Obse (616)\To Be A Jew_ A Guide To Jewish - R Hayim H. Donin.epub is not a valid EPUB file (could not find opf)

---------------

Revision history for this message
Eli Schwartz (eschwartz) wrote : Re: [Bug 1627558] [NEW] Epub corrupted after editing

calibre atomically updates the book when saving -- whatever happened to
that book was almost definitely something other than calibre. Also, no
problems were reported when saving, as you said. ;)

If you rename the *.epub to a *.zip and try opening it with an archive
utility, do you see any (legible) contents?

Revision history for this message
Rachmiel Langer (rlanger-langertcc) wrote :
Download full text (3.4 KiB)

The only file in the zip file is the last entry that I edited through Calibre edit book: index-split-099.html. It is a readable html file. The zip archive also lists a file mimetype but nothing else. The total file size of the epub (4 kb) is way smaller than it was during previous edits. All the previous edited & subsequent as yet unedited chapters, style sheets & images all seem to have dropped from the epub.

I've not accessed this book through anything other than editing or reading in Calibre (and it was originally created in Calibre by converting an htmlz file to epub.)

Thanks.

Rachmiel

-----Original Message-----
From: Eli Schwartz <email address hidden>
To: <email address hidden>
Sent: Sun, 25 Sep 2016 8:19 PM
Subject: Re: [Bug 1627558] [NEW] Epub corrupted after editing

calibre atomically updates the book when saving -- whatever happened to
that book was almost definitely something other than calibre. Also, no
problems were reported when saving, as you said. ;)

If you rename the *.epub to a *.zip and try opening it with an archive
utility, do you see any (legible) contents?

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/1627558

Title:
  Epub corrupted after editing

Status in calibre:
  New

Bug description:
  After editing an epub through the Calibre editor (& accessing the book
  fine), at some point after making additional edits & saving the book
  with no reported problem, the book is no longer accessible. This is
  after editing about 100 index split html files. Is there any way to
  recover the edited book?

  This is under Calibre version 2.67 (64 bit),
  Windows 7 Home Premium, service pack 1

  The following error shows when trying to edit the book again,

  Failed to open book

  Details show:

  calibre, version 2.67.0
  ERROR: Failed to open book: Failed to open book, click Show details for more information.

  Traceback (most recent call last):
    File "site-packages\calibre\gui2\tweak_book\job.py", line 34, in run
    File "site-packages\calibre\gui2\tweak_book\boss.py", line 57, in get_container
    File "site-packages\calibre\ebooks\oeb\polish\container.py", line 1418, in get_container
    File "site-packages\calibre\ebooks\oeb\polish\container.py", line 1084, in __init__
  InvalidEpub: No META-INF/container.xml in epub

  ---------------

  Just trying to read it read yields:

  Failed to read book

  Details shows:

  calibre, version 2.67.0
  ERROR: Could not open ebook: Failed to read book, D:\My Documents\Calibre Library\R Hayim H. Donin\To Be A Jew_ A Guide To Jewish Obse (616)\To Be A Jew_ A Guide To Jewish - R Hayim H. Donin.epub click "Show Details" for more information

  Traceback (most recent call last):
    File "site-packages\calibre\utils\ipc\simple_worker.py", line 276, in main
    File "site-packages\calibre\ebooks\oeb\iterator\book.py", line 62, in extract_book
    File "site-packages\calibre\customize\conversion.py", line 241, in __call__
    File "site-packages\calibre\ebooks\conversion\plugins\epub_input.py", line 246, in convert
  ValueError: D:\My Documents\Calibre Library\R Hayim H. Donin\To Be A Jew_ A Guide To J...

Read more...

Revision history for this message
Kovid Goyal (kovid) wrote :

No, there is no way to recover previous versions of a file after saving them. Presumably you still have the htmlz so you can regenerate the epub from that. As far as I know, there is no way for the editor to ever create an EPUB file that has no opf and no EPUB file structure.

If you can isolate a sequence of steps to reproduce the problem, do let me know.

Changed in calibre:
status: New → Incomplete
Revision history for this message
SteveB (steveb-m) wrote :

fwiw I have had this or very similar experience also, quite a few times, it occurs when you combine (a) long periods of editing and (b) editing many books simultaneously. If you close all the Calibres you can see odd calibres still left in the tasklist which you have to cancel manually.
Never bothered to report it myself but it's real.

Revision history for this message
Kovid Goyal (kovid) wrote :

Saving in the editor happens in two steps:

1) The EPUB file is generated in a temporary file
2) Only if writing the EPUB file completes successfully, the original file is replaced, atomically (via a file rename) with the new file.

Individual editor instances are completely independent processes, they do not interact in any way, whatsoever, so I dont see why having multiple copies of editors open at the same time should make a difference. Even if you try to edit the same EPUB file in all the editors, the above process still means that they cannot corrupt your EPUB file. Regardless, I tried launching 20 editors (on different epub files) and I cannot reproduce.

So I still need a set of reproducible steps, without that I can see no way to move forward.

Changed in calibre:
status: Incomplete → New
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for calibre because there has been no activity for 60 days.]

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