sources: check if ostree object exists in cache

The generic ways of checking if an object is in the cache does not apply
for ostree as the internal structure of a repo is quite specific. Thus
we need to use the ostree executable to ask it to explore its repo for
us.
This commit is contained in:
Thomas Lavocat 2022-05-06 17:35:32 +02:00 committed by Thomas Lavocat
parent 441e67a6f6
commit ac2a194cd4

View file

@ -11,6 +11,7 @@ import os
import sys
import subprocess
import uuid
from osbuild.util.ostree import show
from osbuild import sources
@ -122,8 +123,12 @@ class OSTreeSource(sources.SourceService):
ostree("config", "set", "repo.locking", "true", repo=self.repo)
# pylint: disable=[no-self-use]
def exists(self, _checksum, _item):
return False
def exists(self, checksum, _desc):
try:
show(self.repo, checksum)
except RuntimeError:
return False
return True
def main():