mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
For consistency use suggested_filename in Google Drive (#137061)
Use suggested_filename in Google Drive
This commit is contained in:
parent
9453b925cd
commit
bb61e31298
@ -11,7 +11,7 @@ from aiohttp import ClientSession, ClientTimeout, StreamReader
|
|||||||
from aiohttp.client_exceptions import ClientError, ClientResponseError
|
from aiohttp.client_exceptions import ClientError, ClientResponseError
|
||||||
from google_drive_api.api import AbstractAuth, GoogleDriveApi
|
from google_drive_api.api import AbstractAuth, GoogleDriveApi
|
||||||
|
|
||||||
from homeassistant.components.backup import AgentBackup
|
from homeassistant.components.backup import AgentBackup, suggested_filename
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.exceptions import (
|
from homeassistant.exceptions import (
|
||||||
@ -132,7 +132,7 @@ class DriveClient:
|
|||||||
"""Upload a backup."""
|
"""Upload a backup."""
|
||||||
folder_id, _ = await self.async_create_ha_root_folder_if_not_exists()
|
folder_id, _ = await self.async_create_ha_root_folder_if_not_exists()
|
||||||
backup_metadata = {
|
backup_metadata = {
|
||||||
"name": f"{backup.name} {backup.date}.tar",
|
"name": suggested_filename(backup),
|
||||||
"description": json.dumps(backup.as_dict()),
|
"description": json.dumps(backup.as_dict()),
|
||||||
"parents": [folder_id],
|
"parents": [folder_id],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -140,7 +140,7 @@
|
|||||||
tuple(
|
tuple(
|
||||||
dict({
|
dict({
|
||||||
'description': '{"addons": [{"name": "Test", "slug": "test", "version": "1.0.0"}], "backup_id": "test-backup", "date": "2025-01-01T01:23:45.678Z", "database_included": true, "extra_metadata": {"with_automatic_settings": false}, "folders": [], "homeassistant_included": true, "homeassistant_version": "2024.12.0", "name": "Test", "protected": false, "size": 987}',
|
'description': '{"addons": [{"name": "Test", "slug": "test", "version": "1.0.0"}], "backup_id": "test-backup", "date": "2025-01-01T01:23:45.678Z", "database_included": true, "extra_metadata": {"with_automatic_settings": false}, "folders": [], "homeassistant_included": true, "homeassistant_version": "2024.12.0", "name": "Test", "protected": false, "size": 987}',
|
||||||
'name': 'Test 2025-01-01T01:23:45.678Z.tar',
|
'name': 'Test_-_2025-01-01_01.23_45678000.tar',
|
||||||
'parents': list([
|
'parents': list([
|
||||||
'HA folder ID',
|
'HA folder ID',
|
||||||
]),
|
]),
|
||||||
@ -211,7 +211,7 @@
|
|||||||
tuple(
|
tuple(
|
||||||
dict({
|
dict({
|
||||||
'description': '{"addons": [{"name": "Test", "slug": "test", "version": "1.0.0"}], "backup_id": "test-backup", "date": "2025-01-01T01:23:45.678Z", "database_included": true, "extra_metadata": {"with_automatic_settings": false}, "folders": [], "homeassistant_included": true, "homeassistant_version": "2024.12.0", "name": "Test", "protected": false, "size": 987}',
|
'description': '{"addons": [{"name": "Test", "slug": "test", "version": "1.0.0"}], "backup_id": "test-backup", "date": "2025-01-01T01:23:45.678Z", "database_included": true, "extra_metadata": {"with_automatic_settings": false}, "folders": [], "homeassistant_included": true, "homeassistant_version": "2024.12.0", "name": "Test", "protected": false, "size": 987}',
|
||||||
'name': 'Test 2025-01-01T01:23:45.678Z.tar',
|
'name': 'Test_-_2025-01-01_01.23_45678000.tar',
|
||||||
'parents': list([
|
'parents': list([
|
||||||
'new folder id',
|
'new folder id',
|
||||||
]),
|
]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user