mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Protect backup manager from setup failures for mount down (#4327)
This commit is contained in:
parent
b86a6d292f
commit
3c3846240d
@ -33,10 +33,13 @@ _LOGGER: logging.Logger = logging.getLogger(__name__)
|
|||||||
def _list_backup_files(path: Path) -> Iterable[Path]:
|
def _list_backup_files(path: Path) -> Iterable[Path]:
|
||||||
"""Return iterable of backup files, suppress and log OSError for network mounts."""
|
"""Return iterable of backup files, suppress and log OSError for network mounts."""
|
||||||
try:
|
try:
|
||||||
return path.glob("*.tar")
|
# is_dir does a stat syscall which raises if the mount is down
|
||||||
|
if path.is_dir():
|
||||||
|
return path.glob("*.tar")
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
_LOGGER.error("Could not list backups from %s: %s", path.as_posix(), err)
|
_LOGGER.error("Could not list backups from %s: %s", path.as_posix(), err)
|
||||||
return []
|
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class BackupManager(FileConfiguration, CoreSysAttributes):
|
class BackupManager(FileConfiguration, CoreSysAttributes):
|
||||||
|
@ -690,7 +690,7 @@ async def test_load_network_error(
|
|||||||
|
|
||||||
# This should not raise, manager should just ignore backup locations with errors
|
# This should not raise, manager should just ignore backup locations with errors
|
||||||
mock_path = MagicMock()
|
mock_path = MagicMock()
|
||||||
mock_path.glob.side_effect = OSError("Host is down")
|
mock_path.is_dir.side_effect = OSError("Host is down")
|
||||||
mock_path.as_posix.return_value = "/data/backup_test"
|
mock_path.as_posix.return_value = "/data/backup_test"
|
||||||
with patch.object(Mount, "local_where", new=PropertyMock(return_value=mock_path)):
|
with patch.object(Mount, "local_where", new=PropertyMock(return_value=mock_path)):
|
||||||
await coresys.backups.load()
|
await coresys.backups.load()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user