pedia / epub3

epub3 read and write
1 stars 0 forks source link

modifying an existing epub does not work #2

Open denniskaselow opened 1 month ago

denniskaselow commented 1 month ago

When reading an existing epub (for example when you want to modify it) and and then writing it, the content of all existing chapters is lost. This happens because the chapter content is never loaded when creating a Chapter (no content parameter is passed) while reading the epub file:

https://github.com/pedia/epub3/blob/8ed5c7b098b88c5fd359815c6ad96c33c458fa45/epub3/lib/src/reader.dart#L268-L272

So when writing the epub again, content is null and no file containing the content is added to the file.

https://github.com/pedia/epub3/blob/8ed5c7b098b88c5fd359815c6ad96c33c458fa45/epub3/lib/src/writer.dart#L49-L61

I suppose the tests are green because they only test for the chapter title, which still exists in the nav-file.

pedia commented 3 weeks ago

Sorry for late reply: I missed notify from Github.

In reading process, not read content purpose for memory reducing of HUGE epub-files. Maybe adding a optional argument is better?

  Reader.read({withContent: true})

I have enough time to fix it.