updates: read installed version from addon.xml on disk
This commit is contained in:
@@ -1283,14 +1283,32 @@ def _settings_key_for_plugin(name: str) -> str:
|
||||
return f"update_version_{safe}" if safe else "update_version_unknown"
|
||||
|
||||
|
||||
def _installed_addon_version_from_disk() -> str:
|
||||
if xbmcvfs is None:
|
||||
return "0.0.0"
|
||||
try:
|
||||
addon_xml = xbmcvfs.translatePath(f"special://home/addons/{UPDATE_ADDON_ID}/addon.xml")
|
||||
except Exception:
|
||||
return "0.0.0"
|
||||
if not addon_xml or not os.path.exists(addon_xml):
|
||||
return "0.0.0"
|
||||
try:
|
||||
root = ET.parse(addon_xml).getroot()
|
||||
version = str(root.attrib.get("version") or "").strip()
|
||||
return version or "0.0.0"
|
||||
except Exception:
|
||||
return "0.0.0"
|
||||
|
||||
|
||||
def _sync_update_version_settings() -> None:
|
||||
addon = _get_addon()
|
||||
addon_version = "0.0.0"
|
||||
if addon is not None:
|
||||
try:
|
||||
addon_version = str(addon.getAddonInfo("version") or "0.0.0")
|
||||
except Exception:
|
||||
addon_version = "0.0.0"
|
||||
addon_version = _installed_addon_version_from_disk()
|
||||
if addon_version == "0.0.0":
|
||||
addon = _get_addon()
|
||||
if addon is not None:
|
||||
try:
|
||||
addon_version = str(addon.getAddonInfo("version") or "0.0.0")
|
||||
except Exception:
|
||||
addon_version = "0.0.0"
|
||||
_set_setting_string("update_version_addon", addon_version)
|
||||
_set_setting_string("update_installed_version", addon_version)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user