fix(agent): remove infinite loop and account for externally removed

images
web-stuff
Jef Roosens 2022-12-15 12:09:43 +01:00
parent b634775ca3
commit dbbe5c1e51
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 15 additions and 1 deletions

View File

@ -73,7 +73,21 @@ fn (mut m ImageManager) clean_old_images() {
// wasn't deleted. Therefore, we move the index over. If the function
// returns true, the array's length has decreased by one so we don't
// move the index.
dd.remove_image(m.images[image][i]) or { i += 1 }
dd.remove_image(m.images[image][i]) or {
// The image was removed by an external event
if err.code() == 404 {
m.images[image].delete(i)
}
// The image couldn't be removed, so we need to keep track of
// it
else {
i += 1
}
continue
}
m.images[image].delete(i)
}
}
}