Refactor golden image handling in backup upload process</message>
<message>Update the _set_golden_from_path function to improve the handling of existing golden image files. Replace the existing unlink logic with a more robust method that safely removes files or broken symlinks using the missing_ok parameter. This change enhances the reliability of the backup upload process by ensuring that stale references are properly cleared before setting a new golden image path.
This commit is contained in:
@@ -1175,8 +1175,8 @@ def api_backups_upload():
|
||||
def _set_golden_from_path(path):
|
||||
"""Set golden image to point to given path (file in backups or cloudinit dir)."""
|
||||
GOLDEN_IMAGE.parent.mkdir(parents=True, exist_ok=True)
|
||||
if GOLDEN_IMAGE.exists():
|
||||
GOLDEN_IMAGE.unlink()
|
||||
# Remove existing file or symlink (including broken symlink; exists() is False for broken links)
|
||||
GOLDEN_IMAGE.unlink(missing_ok=True)
|
||||
path_resolved = path.resolve()
|
||||
try:
|
||||
path_resolved.relative_to(BACKUPS_DIR.resolve())
|
||||
|
||||
Reference in New Issue
Block a user