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.
This commit is contained in:
Thomas Lavocat 2022-05-10 13:11:04 +02:00 committed by Thomas Lavocat
parent 128845da3c
commit 0953cf64e0
2 changed files with 4 additions and 3 deletions

View file

@ -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")