custom_components/bahmcloud_store/core.py aktualisiert
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -157,13 +158,25 @@ class BCSCore:
|
|||||||
|
|
||||||
async def _load_index_repos(self) -> tuple[list[RepoItem], int]:
|
async def _load_index_repos(self) -> tuple[list[RepoItem], int]:
|
||||||
session = async_get_clientsession(self.hass)
|
session = async_get_clientsession(self.hass)
|
||||||
|
|
||||||
|
# ---- CACHE BUSTING FIX (Phase B) ----
|
||||||
|
# Force store.yaml to always be reloaded from remote:
|
||||||
|
# - add timestamp query parameter
|
||||||
|
# - disable HTTP cache via headers
|
||||||
|
url = f"{self.config.store_url}?t={int(time.time())}"
|
||||||
|
headers = {
|
||||||
|
"Cache-Control": "no-cache",
|
||||||
|
"Pragma": "no-cache",
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with session.get(self.config.store_url, timeout=20) as resp:
|
async with session.get(url, timeout=20, headers=headers) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
raise BCSError(f"store_url returned {resp.status}")
|
raise BCSError(f"store_url returned {resp.status}")
|
||||||
raw = await resp.text()
|
raw = await resp.text()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise BCSError(f"Failed fetching store index: {e}") from e
|
raise BCSError(f"Failed fetching store index: {e}") from e
|
||||||
|
# ---- END CACHE BUSTING FIX ----
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = ha_yaml.parse_yaml(raw)
|
data = ha_yaml.parse_yaml(raw)
|
||||||
|
|||||||
Reference in New Issue
Block a user