snaplist: fix snaplist with filesystem without snaps

When no snaps are seeded in the filesystem, empty string is returned,
which yaml safe load interprets as None.

But snapd seed.yaml is defined as a dictionary with snaps key. Ensure
that when no seed.yaml is present (or readable), that at least an
empty dictionary is returned, such that later calls to `.get("snaps",
[])` succeed.

LP: #1889429
This commit is contained in:
Dimitri John Ledkov 2020-07-29 16:24:25 +01:00
parent 3d4158dde3
commit c7aff1fed5
No known key found for this signature in database
GPG Key ID: 9B8EC849D5EF70ED
1 changed files with 1 additions and 1 deletions

View File

@ -426,7 +426,7 @@ class SnapListView(BaseView):
file: lxd_59.snap
'''
seed_location = '/media/filesystem/var/lib/snapd/seed/seed.yaml'
content = ""
content = "{}"
try:
with open(seed_location, encoding='utf-8', errors='replace') as fp:
content = fp.read()