From 0953cf64e0988aa5743c1c6aed04b69cd49b9410 Mon Sep 17 00:00:00 2001 From: Thomas Lavocat Date: Tue, 10 May 2022 13:11:04 +0200 Subject: [PATCH] sources: provide an unverified tmpdir Some downloading program need a global unverified tmpdir to work within before storing the definitive data. Provide this in the workflow directly. --- osbuild/sources.py | 4 +++- sources/org.osbuild.inline | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osbuild/sources.py b/osbuild/sources.py index 74fc4e6e..7c572a6b 100644 --- a/osbuild/sources.py +++ b/osbuild/sources.py @@ -55,6 +55,7 @@ class SourceService(host.Service): super().__init__(*args, **kwargs) self.cache = None self.options = None + self.tmpdir = None @abc.abstractmethod def download(self, items): @@ -80,6 +81,7 @@ class SourceService(host.Service): def dispatch(self, method: str, args, fds): if method == "download": self.setup(args) - return self.download(SourceService.load_items(fds)), None + with tempfile.TemporaryDirectory(prefix=".unverified-", dir=self.cache) as self.tmpdir: + return self.download(SourceService.load_items(fds)), None raise host.ProtocolError("Unknown method") diff --git a/sources/org.osbuild.inline b/sources/org.osbuild.inline index 53098d18..e13116f0 100755 --- a/sources/org.osbuild.inline +++ b/sources/org.osbuild.inline @@ -84,8 +84,7 @@ class InlineSource(sources.SourceService): content_type = "org.osbuild.files" def download(self, items): - with tempfile.TemporaryDirectory(prefix=".unverified-", dir=self.cache) as tmpdir: - process(items, self.cache, tmpdir) + process(items, self.cache, self.tmpdir) def main():