Skip to content

Commit

Permalink
fix: improve error message and handling when unable to purge a backup
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed Jan 6, 2025
1 parent 7699305 commit 770554b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions custom_components/auto_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,16 @@ async def _purge_snapshot(self, slug):
_LOGGER.debug("Attempting to remove backup: %s", slug)
try:
await self._handler.remove_backup(slug)
# remove snapshot expiry.
del self._snapshots[slug]
except HassioAPIError as err:
message = "Failed to purge backup: %s, If it was intentionally moved or deleted externally you can ignore this error."
if str(err) == "Backup does not exist":
del self._snapshots[slug]
_LOGGER.warning(message, err)
else:
_LOGGER.error("Failed to purge backup: %s", err)
return False
_LOGGER.error(message, err)
return False
finally:
# remove snapshot expiry.
del self._snapshots[slug]
return True

def async_download_backup(self, name, slug, backup_path):
Expand Down

0 comments on commit 770554b

Please sign in to comment.