From a4c22636cea523fa809eaa4a5f15c85532f806ed Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 23 Jun 2022 13:04:59 +0000 Subject: [PATCH] export: Don't fail when output stream isn't seekable 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 Signed-off-by: Michael Tremer --- src/python/location/export.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/python/location/export.py b/src/python/location/export.py index 054e494..f5ed37f 100644 --- a/src/python/location/export.py +++ b/src/python/location/export.py @@ -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() -- 2.39.5