diff --git a/custom_components/bahmcloud_store/storage.py b/custom_components/bahmcloud_store/storage.py index 1fe35f5..4d8540a 100644 --- a/custom_components/bahmcloud_store/storage.py +++ b/custom_components/bahmcloud_store/storage.py @@ -25,8 +25,9 @@ class InstalledRepo: url: str domains: list[str] installed_at: int - installed_version: str | None = None - ref: str | None = None + installed_version: str | None = None # BCS "installed ref" (tag/release/branch) + installed_manifest_version: str | None = None # informational only + ref: str | None = None # kept for backward compatibility / diagnostics class BCSStorage: @@ -110,13 +111,24 @@ class BCSStorage: domains = [] domains = [str(d) for d in domains if str(d).strip()] + installed_version = entry.get("installed_version") + ref = entry.get("ref") + + # Backward compatibility: + # If installed_version wasn't stored, fall back to ref. + if (not installed_version) and ref: + installed_version = ref + + installed_manifest_version = entry.get("installed_manifest_version") + return InstalledRepo( repo_id=str(entry.get("repo_id") or repo_id), url=str(entry.get("url") or ""), domains=domains, installed_at=int(entry.get("installed_at") or 0), - installed_version=str(entry.get("installed_version")) if entry.get("installed_version") else None, - ref=str(entry.get("ref")) if entry.get("ref") else None, + installed_version=str(installed_version) if installed_version else None, + installed_manifest_version=str(installed_manifest_version) if installed_manifest_version else None, + ref=str(ref) if ref else None, ) except Exception: return None @@ -127,8 +139,8 @@ class BCSStorage: out: list[InstalledRepo] = [] if not isinstance(installed, dict): return out - for repo_id in list(installed.keys()): - item = await self.get_installed_repo(str(repo_id)) + for rid in list(installed.keys()): + item = await self.get_installed_repo(str(rid)) if item: out.append(item) return out @@ -140,6 +152,7 @@ class BCSStorage: url: str, domains: list[str], installed_version: str | None, + installed_manifest_version: str | None = None, ref: str | None, ) -> None: data = await self._load() @@ -153,7 +166,11 @@ class BCSStorage: "url": str(url), "domains": [str(d) for d in (domains or []) if str(d).strip()], "installed_at": int(time.time()), + # IMPORTANT: this is what BCS uses as "installed version" (ref/tag/branch) "installed_version": installed_version, + # informational only + "installed_manifest_version": installed_manifest_version, + # keep ref too (debug/backward compatibility) "ref": ref, } await self._save(data)