MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   [Plugin] DeleteUnmanifestedFiles (https://www.mobileread.com/forums/showthread.php?t=291005)

Doitsu 10-06-2017 03:46 AM

[Plugin] DeleteUnmanifestedFiles
 
1 Attachment(s)
Updated: 8 October 2019
Current Version: "0.1.2"

This simple plugin will delete files that third-party apps might write to the ePub temp folder.
Note that this plugin will delete all unmanifested files, except for files in the META-INF folder.
For example, it won't delete com.apple.ibooks.display-options.xml.

Installation:

1. Select Manage Plugins from the Plugins menu and select Use Bundled Python, if it isn't already selected.
2. Click Add Plugin and select DeleteUnmanifestedFiles_v0.1.2.zip. This will install the DeleteUnmanifestedFiles edit plugin, which you can select via Plugins > Edit > DeleteUnmanifestedFiles.

License: GNU General Public License v3 (GPL-3)

jcsalomon 10-10-2017 05:49 PM

Quote:

Originally Posted by DiapDealer (Post 3589234)
Also ... I'm sure there's probably more "allowable" unmanifested files that will only become apparent after you've released your plugin (not that I can think of any offhand). A way for the user to exempt specific files (or file-types) might stave off future trouble. :)

Here’s an example. I’m using a font whose license says, “If you redistribute the font file in this archive, it must be accompanied by all the other files from this archive, including this one.” The most straightforward way to comply with this is to include the Readme.txt and License.txt files in the EPUB’s Misc folder but (since nobody who’s just reading the book ever has to see those files) not include them in the manifest.

… On second look, actually they do seem to have entries in content.opf’s <manifest> section, since I added them via Sigil’s interface. But ought they to?

DiapDealer 10-10-2017 06:00 PM

Quote:

Originally Posted by jcsalomon (Post 3591631)
… On second look, actually they do seem to have entries in content.opf’s <manifest> section, since I added them via Sigil’s interface. But ought they to?

Not sure really. But they will probably cause warnings/errors with validators either way: manifested but unused, or unmanifested members of the archive.

But as mentioned elsewhere, totally unmanifested files (except for the special mimetype file and what's in the META-INF folder) won't likely survive consecutive Sigil saves anyway.

Doitsu 10-10-2017 06:08 PM

Quote:

Originally Posted by jcsalomon (Post 3591631)
Here’s an example.The most straightforward way to comply with this is to include the Readme.txt and License.txt files in the EPUB’s Misc folder[...]

IMHO, the most straightforward way would be to drop these files in the META-INF folder, because it isn't checked by epubcheck.
(Epubcheck only checks for the presence of container.xml and the content.opf path.)
However, since Sigil will delete .txt files from the META-INF folder upon opening the ePub, you'll have to add them after you've finalized the epub.

jcsalomon 10-10-2017 06:25 PM

Quote:

Originally Posted by DiapDealer (Post 3591633)
Not sure really. But they will probably cause warnings/errors with validators either way: manifested but unused, or unmanifested members of the archive.

EpubCheck, at least, is happy with manifested but unused, and since…

Quote:

Originally Posted by DiapDealer (Post 3591633)
But as mentioned elsewhere, totally unmanifested files (except for the special mimetype file and what's in the META-INF folder) won't likely survive consecutive Sigil saves anyway.

… I think I’ll stick with what I’m doing: manifested files in Misc/ which are not referenced otherwise.

KevinH 10-16-2017 11:51 AM

BTW: If unmanifested files are present in an ebook at the time a plugin is launched you can get access to all unmanifested files in bk.other_iter() and you should be able to use the normal interface to delete them.

Code:

    # all other ebook files not in the manifest
    print("\nExercising: bk.other_iter()")
    for book_href in bk.other_iter():
        print(book_href)

obviously deleting META-INF/container.xml or the OEBPS/content.opf would not be a good idea ;-) but that iterator should give you the names of all unmanifested files to play with.

So please consider trying the provided iterator approach and if you run into trouble, let me know and I will fix any unearthed bugs.


All times are GMT -4. The time now is 08:52 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.