supervisor/backup: Ensure compressed flag is respected by homeassistant (#3839)

As per commit 80e67b3 we're supporting a compressed flag on backups to
define whether a tar archive should be fully compressed or not, but
while we respect this for all the addons and folders we don't do it for
the actual homeassistant archive, that is always compressed despite the
passed flag.

Fix this by applying the same logic to the homeassistant archive too.
This commit is contained in:
Marco Trevisan 2022-09-02 09:21:33 +02:00 committed by GitHub
parent dcd0592d44
commit 2dab39bf90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -465,8 +465,11 @@ class Backup(CoreSysAttributes):
self._data[ATTR_HOMEASSISTANT] = {ATTR_VERSION: self.sys_homeassistant.version}
# Backup Home Assistant Core config directory
tar_name = Path(
self._tmp.name, f"homeassistant.tar{'.gz' if self.compressed else ''}"
)
homeassistant_file = SecureTarFile(
Path(self._tmp.name, "homeassistant.tar.gz"), "w", key=self._key
tar_name, "w", key=self._key, gzip=self.compressed
)
await self.sys_homeassistant.backup(homeassistant_file)
@ -479,8 +482,11 @@ class Backup(CoreSysAttributes):
await self.sys_homeassistant.core.stop()
# Restore Home Assistant Core config directory
tar_name = Path(
self._tmp.name, f"homeassistant.tar{'.gz' if self.compressed else ''}"
)
homeassistant_file = SecureTarFile(
Path(self._tmp.name, "homeassistant.tar.gz"), "r", key=self._key
tar_name, "r", key=self._key, gzip=self.compressed
)
await self.sys_homeassistant.restore(homeassistant_file)