The OperationBuffer is responsible for buffering ZIM write operations until they can be completed.
Due to the way compression works, it is possible that some operations like pyzim.archive.Zim.add_full_url_redirect can only be completed after a new cluster has been written. As force-flushing the compression strategy every time this happens would lead to potentially suboptimal compression, we have to buffer these operations until they can be completed. This class is responsible for this.
| Method | __init__ |
The default constructor. |
| Method | buffer |
Buffer an add_redirect operation. |
| Method | buffer |
Buffer a set_mainpage_url operation. |
| Method | finalize |
Finalize all operations that require other entries to be written first. |
| Instance Variable | zim |
ZIM archiveto buffer operations for |
| Method | _apply |
Apply previously buffered add_redirect operations. |
| Method | _apply |
Apply any previously buffered set_mainpage_url operation. |
| Instance Variable | _buffered |
the buffered value for the next mainpage url setting (or False if none buffered) |
| Instance Variable | _buffered |
a list of (source full url, target full url, title) of redirects that need yet to be written |
Buffer a set_mainpage_url operation.
See pyzim.archive.Zim.set_mainpage_url for details.
Any such previously buffered operations are replaced.
| Parameters | |
url:str or None | non-full url of mainpage to set (or None to disable mainapge) |
Finalize all operations that require other entries to be written first.
NOTE: currently, access to the title pointer list entries is not available.
| Raises | |
pyzim.exceptions.UnresolvedRedirect | when a redirect target could not be resolved |
Apply previously buffered add_redirect operations.
| Raises | |
pyzim.exceptions.UnresolvedRedirect | when a redirect target can not be resolved |
Apply any previously buffered set_mainpage_url operation.
| Raises | |
pyzim.exceptions.UnresolvedRedirect | If the redirect for the mainpage can not be resolved. |