sources: introduce per-source content_type

Introduce a new class member `content_type` that specifies what type of
items the source will store in the cache. Use that to generalize the
setup step, which is shared across all sources.
This commit is contained in:
Thomas Lavocat 2022-05-10 12:54:08 +02:00 committed by Thomas Lavocat
parent 34cd9ef9f0
commit 92fe237f24
5 changed files with 23 additions and 11 deletions

View file

@ -81,9 +81,10 @@ def process(items: Dict, cache: str, tmpdir):
class InlineSource(sources.SourceService):
def download(self, items, cache, _options):
self.setup(cache, "org.osbuild.files")
with tempfile.TemporaryDirectory(prefix=".unverified-", dir=cache) as tmpdir:
content_type = "org.osbuild.files"
def download(self, items, _cache, _options):
with tempfile.TemporaryDirectory(prefix=".unverified-", dir=self.cache) as tmpdir:
process(items, self.cache, tmpdir)