comicbox.box.archive.rollback ¶
Put an archive’s tail back when a write to it in place fails.
A re-tag of a CBZ rewrites only its tail: every byte from the first one the write can change to the end of the file, which holds the trailing tag files, the central directory and the end record. TailRollback keeps the old tail and length in memory while that happens. If the write raises anything, a keyboard interrupt included, the tail is written back and the file cut to its old length, so the comic is as it was. A process killed part way can leave the tag files damaged; the pages are never touched.
TailRollback ¶
Keep an archive’s tail in memory while it is rewritten in place.
Source code in comicbox/box/archive/rollback.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
__enter__() ¶
Keep the tail and the length before anything changes.
Source code in comicbox/box/archive/rollback.py
49 50 51 52 53 54 55 | |
__exit__(exc_type, exc, traceback) ¶
Put the tail back if the write raised; the error is raised as before.
Source code in comicbox/box/archive/rollback.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
__init__(path, offset) ¶
Name the archive and the first byte the write can change.
Source code in comicbox/box/archive/rollback.py
42 43 44 45 46 47 | |