sources: generalize cache generation

Introduce a `setup` step in the workflow that is responsible of
generating the cache folder. This is then used in each download method.
This commit is contained in:
Thomas Lavocat 2022-05-10 12:48:27 +02:00 committed by Thomas Lavocat
parent 5337374b50
commit 34cd9ef9f0
5 changed files with 12 additions and 14 deletions

View file

@ -54,6 +54,10 @@ class SourceService(host.Service):
def download(self, items, cache, options):
pass
def setup(self, cache, content_type):
self.cache = os.path.join(cache, content_type)
os.makedirs(self.cache, exist_ok=True)
def dispatch(self, method: str, args, fds):
if method == "download":
with os.fdopen(fds.steal(0)) as f: