Skip to content

Commit 70640c3

Browse files
committed
cmd-prune: skip removing "unowned" blobs if 'layers' field doesn't exist
Older images doesn't have 'layers' field in the oci manifest. Fixes: #4310
1 parent 4ec5990 commit 70640c3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmd-prune

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ if os.path.exists('tmp/repo'):
198198
if os.path.exists(oci_manifest):
199199
with open(oci_manifest) as f:
200200
oci_manifest = json.load(f)
201+
layers = oci_manifest.get('layers', [])
202+
if len(layers) == 0:
203+
continue
201204
referenced_blobs.update([prefix + layer['digest'].replace(':', '_3A_')
202-
for layer in oci_manifest['layers']])
205+
for layer in layers])
203206
blobs = set(subprocess.check_output(['ostree', 'refs', '--repo=tmp/repo',
204207
'--list', 'ostree/container/blob'],
205208
encoding='utf-8').splitlines())

0 commit comments

Comments
 (0)