# Write all domains to the buffer
exporter(f)
+ # Write the file
+ self._write_file(tarball, file, f)
+
+ # squidguard is also expecting some more files
+ for name in ("expressions", "urls"):
+ file = tarfile.TarInfo(name="%s/%s" % (self.list.slug, name))
+
+ self._write_file(tarball, file)
+
+ def _write_file(self, tarball, file, f=None):
+ """
+ A helper function to set some commonly used metadata
+ """
# Assign the list to be owned by nobody
file.uname = file.gname = "nobody"
- # Set the length
- file.size = f.tell()
-
# Set the mtime
file.mtime = self.list.updated_at.timestamp()
- # Reset the buffer
- f.seek(0)
+ # Set the length
+ if f:
+ file.size = f.tell()
+
+ # Ensure we read the payload from the beginning
+ if f:
+ f.seek(0)
# Write the buffer to the tarball
tarball.addfile(file, fileobj=f)