Ignore missing backup file on error (#5910)

When a backup error occurs, it might be that the backup file hasn't
been created yet, e.g. when there is no space or no permission on
the target backup directory. Deleting the backup file would fail
in this case. Use missing_ok instead to ignore a missing backup file
on delete.
This commit is contained in:
Stefan Agner 2025-05-23 14:29:36 +02:00 committed by GitHub
parent 7593f857e8
commit bbb8fa0b92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -552,12 +552,12 @@ class BackupManager(FileConfiguration, JobGroup):
self._change_stage(BackupJobStage.FINISHING_FILE, backup) self._change_stage(BackupJobStage.FINISHING_FILE, backup)
except BackupError as err: except BackupError as err:
await self.sys_run_in_executor(backup.tarfile.unlink) await self.sys_run_in_executor(backup.tarfile.unlink, missing_ok=True)
_LOGGER.error("Backup %s error: %s", backup.slug, err) _LOGGER.error("Backup %s error: %s", backup.slug, err)
self.sys_jobs.current.capture_error(err) self.sys_jobs.current.capture_error(err)
return None return None
except Exception as err: # pylint: disable=broad-except except Exception as err: # pylint: disable=broad-except
await self.sys_run_in_executor(backup.tarfile.unlink) await self.sys_run_in_executor(backup.tarfile.unlink, missing_ok=True)
_LOGGER.exception("Backup %s error", backup.slug) _LOGGER.exception("Backup %s error", backup.slug)
await async_capture_exception(err) await async_capture_exception(err)
self.sys_jobs.current.capture_error( self.sys_jobs.current.capture_error(