mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Avoid backup size difference by sorting JSON keys
It seems that the order of keys in the `homeassistant.json` file leads to a different homeassistant.tar.gz size, which in turn leads to a different overall backup size. It seems that running the full test suite compared to run tests individually lead to a different order of keys in the JSON file. This PR sorts the keys when dumping the JSON. With that change, the backup size is consistent.
This commit is contained in:
parent
05b648629f
commit
f39f95477f
@ -55,7 +55,8 @@ def write_json_file(jsonfile: Path, data: Any) -> None:
|
||||
orjson.dumps( # pylint: disable=no-member
|
||||
data,
|
||||
option=orjson.OPT_INDENT_2 # pylint: disable=no-member
|
||||
| orjson.OPT_NON_STR_KEYS, # pylint: disable=no-member
|
||||
| orjson.OPT_NON_STR_KEYS # pylint: disable=no-member
|
||||
| orjson.OPT_SORT_KEYS, # pylint: disable=no-member
|
||||
default=json_encoder_default,
|
||||
).decode("utf-8")
|
||||
)
|
||||
|
@ -1035,6 +1035,9 @@ async def test_protected_backup(
|
||||
assert body["data"]["backups"][0]["location"] is None
|
||||
assert body["data"]["backups"][0]["locations"] == [None]
|
||||
assert body["data"]["backups"][0]["protected"] is True
|
||||
|
||||
# NOTE: Maybe it is not safe to compare size here, as random data in the
|
||||
# backup might change the size (due to gzip).
|
||||
assert body["data"]["backups"][0]["location_attributes"] == {
|
||||
".local": {
|
||||
"protected": True,
|
||||
|
Loading…
x
Reference in New Issue
Block a user