For the ipset format, we will rewrite the header after we know the total
number of entries that have been written in order to optimise the hash
table.
When the output stream isn't seekable, we cannot write the header again
which is being fixed in this patch.
Fixes: #12885
Reported-by: Jon Murphy <jon.murphy@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
def _write_footer(self):
# Jump back to the beginning of the file
- self.f.seek(0)
+ try:
+ self.f.seek(0)
+
+ # If the output stream isn't seekable, we won't try writing the header again
+ except io.UnsupportedOperation:
+ return
# Rewrite the header with better configuration
self._write_header()