]> git.ipfire.org Git - location/libloc.git/commitdiff
export: Don't fail when output stream isn't seekable
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Jun 2022 13:04:59 +0000 (13:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Jun 2022 13:04:59 +0000 (13:04 +0000)
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>
src/python/location/export.py

index 054e4942850548b1409024e880e20b1bf8e32ff1..f5ed37f7f2d51e73ff47f1f8b4479d8787203c5e 100644 (file)
@@ -181,7 +181,12 @@ class IpsetOutputWriter(OutputWriter):
 
        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()