-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if backup is still available when accessing #5521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, except for the method name. That could be changed in a follow-up though.
supervisor/api/backups.py
Outdated
@@ -143,11 +143,26 @@ def _ensure_list(item: Any) -> list: | |||
class APIBackups(CoreSysAttributes): | |||
"""Handle RESTful API for backups functions.""" | |||
|
|||
def _extract_slug(self, request): | |||
async def _extract_slug(self, request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method should be renamed since it does (and already did before this PR) more than just get the slug from the request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to _get_backup_by_slug()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I would actually prefer we don't rename it. Or at the very least, please keep _extract
at the beginning. We can change it to _extract_backup_by_slug
if we prefer. But if you look at all the other files under api
, every one that takes an id of something in the resource path has a matching _extract_<x>
method that extracts that id and returns the resource or raises. I'd like to keep that consistency to make these easy to find.
When accessing a backup (e.g. to restore, download or delete it) check if the locations of the backup file are still available. If not, force a backup reload instead.
97353d7
to
b68d381
Compare
This global refresh is not ideal in any case. We've decided to handle missing backups on Core side, and on Supervisor side just update the cache for the backup in question specifically. |
Proposed change
When accessing a backup (e.g. to restore, download or delete it) check if the locations of the backup file are still available. If not, force a backup reload instead.
Type of change
Additional information
Checklist
ruff format supervisor tests
)If API endpoints or add-on configuration are added/changed: