Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
95fbba1d
Unverified
Commit
95fbba1d
authored
3 weeks ago
by
Erik Montnemery
Committed by
GitHub
3 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
Align cloud with changes in BackupAgent (#139766)
parent
46ac44c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/cloud/backup.py
+12
-15
12 additions, 15 deletions
homeassistant/components/cloud/backup.py
with
12 additions
and
15 deletions
homeassistant/components/cloud/backup.py
+
12
−
15
View file @
95fbba1d
...
...
@@ -18,7 +18,12 @@ from hass_nabucasa.cloud_api import (
)
from
hass_nabucasa.files
import
FilesError
,
StorageType
,
calculate_b64md5
from
homeassistant.components.backup
import
AgentBackup
,
BackupAgent
,
BackupAgentError
from
homeassistant.components.backup
import
(
AgentBackup
,
BackupAgent
,
BackupAgentError
,
BackupNotFound
,
)
from
homeassistant.core
import
HomeAssistant
,
callback
from
homeassistant.helpers.aiohttp_client
import
ChunkAsyncStreamIterator
from
homeassistant.helpers.dispatcher
import
async_dispatcher_connect
...
...
@@ -90,9 +95,7 @@ class CloudBackupAgent(BackupAgent):
:param backup_id: The ID of the backup that was returned in async_list_backups.
:return: An async iterator that yields bytes.
"""
if
not
(
backup
:
=
await
self
.
_async_get_backup
(
backup_id
)):
raise
BackupAgentError
(
"
Backup not found
"
)
backup
=
await
self
.
_async_get_backup
(
backup_id
)
try
:
content
=
await
self
.
_cloud
.
files
.
download
(
storage_type
=
StorageType
.
BACKUP
,
...
...
@@ -171,9 +174,7 @@ class CloudBackupAgent(BackupAgent):
:param backup_id: The ID of the backup that was returned in async_list_backups.
"""
if
not
(
backup
:
=
await
self
.
_async_get_backup
(
backup_id
)):
return
backup
=
await
self
.
_async_get_backup
(
backup_id
)
try
:
await
async_files_delete_file
(
self
.
_cloud
,
...
...
@@ -204,16 +205,12 @@ class CloudBackupAgent(BackupAgent):
self
,
backup_id
:
str
,
**
kwargs
:
Any
,
)
->
AgentBackup
|
None
:
)
->
AgentBackup
:
"""
Return a backup.
"""
if
not
(
backup
:
=
await
self
.
_async_get_backup
(
backup_id
)):
return
None
backup
=
await
self
.
_async_get_backup
(
backup_id
)
return
AgentBackup
.
from_dict
(
backup
[
"
Metadata
"
])
async
def
_async_get_backup
(
self
,
backup_id
:
str
,
)
->
FilesHandlerListEntry
|
None
:
async
def
_async_get_backup
(
self
,
backup_id
:
str
)
->
FilesHandlerListEntry
:
"""
Return a backup.
"""
backups
=
await
self
.
_async_list_backups
()
...
...
@@ -221,4 +218,4 @@ class CloudBackupAgent(BackupAgent):
if
backup
[
"
Metadata
"
][
"
backup_id
"
]
==
backup_id
:
return
backup
r
eturn
None
r
aise
BackupNotFound
(
f
"
Backup
{
backup_id
}
not found
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment