versions middleware: don't fail on corrupted apt cache (#27056)

This commit is contained in:
Frédéric Péters 2018-10-07 08:38:48 +02:00
parent 6e33678cb9
commit d1c12504bb
1 changed files with 7 additions and 2 deletions

View File

@ -75,10 +75,15 @@ class VersionMiddleware(object):
if project_name in cls.ENTROUVERT_PACKAGES:
packages_version[project_name] = version
# get versions from Debian packages
debian_cache = None
if apt_cache:
cache = apt_cache.Cache()
try:
debian_cache = apt_cache.Cache()
except SystemError:
pass
if debian_cache:
versions = [(p.name, p.installed.source_name, p.installed.version) \
for p in cache if p.installed and (
for p in debian_cache if p.installed and (
(p.installed and p.installed.origins[0].origin == "Entr'ouvert") or
(p.candidate and p.candidate.origins[0].origin == "Entr'ouvert"))]
for name, project_name, version in versions: