From f75c1c8dfd4cd9738020fc117d584c75d133de4f Mon Sep 17 00:00:00 2001 From: Luke Davis Date: Thu, 21 Mar 2024 06:19:22 -0400 Subject: [PATCH 1/3] Attempt to remove old store record when updating. --- .../addonUpdater/addonUpdateProc.py | 25 ++++++++++++++++--- buildVars.py | 2 +- readme.md | 4 +++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/addon/globalPlugins/addonUpdater/addonUpdateProc.py b/addon/globalPlugins/addonUpdater/addonUpdateProc.py index 1e0eaea..290c6e2 100644 --- a/addon/globalPlugins/addonUpdater/addonUpdateProc.py +++ b/addon/globalPlugins/addonUpdater/addonUpdateProc.py @@ -6,20 +6,26 @@ # The purpose of this module is to provide implementation of add-on update processes and procedures. # Specifically, internals of update check, download, and installation steps. # For update check, this module is responsible for asking different protocols to return update records. -# Note that add-on update record class is striclty part of update procedures/processes. +# Note that add-on update record class is strictly part of update procedures/processes. # Parts will resemble that of extended add-on handler and GUI modules. from __future__ import annotations from typing import Optional, Any from urllib.request import urlopen import enum +import hashlib +import os + import addonHandler import globalVars from logHandler import log -from . import addonUtils -import hashlib import gui import extensionPoints +from NVDAState import WritePaths + +from . import addonUtils + + addonHandler.initTranslation() @@ -228,4 +234,17 @@ def installAddonUpdate(destPath: str, addonName: str) -> int: except Exception: log.error(f"Error installing addon bundle from {destPath}", exc_info=True) return AddonInstallStatus.AddonInstallGenericError + else: # We want to remove any record the store has of this add-on, since we install externally. + # If we don't, the store shows stable add-ons of the same version as our external add-ons, + # as having updates, even though it's just a different instance of the same version. + # The real cause is the older version listed in the store JSON, but the UI can't represent that. + oldStoreRecord: str = os.path.join( + WritePaths.addonsDir, + bundleName + ".json" + ) + try: + os.remove(os.path.abspath(oldStoreRecord)) + log.debug(f"Removed old store record at {oldStoreRecord}") + except OSError: + log.debug(f"Attempt to remove an old store record failed: may not exist. Target: {oldStoreRecord}") return AddonInstallStatus.AddonInstallSuccess diff --git a/buildVars.py b/buildVars.py index 2a66507..7b297c1 100644 --- a/buildVars.py +++ b/buildVars.py @@ -25,7 +25,7 @@ def _(arg): # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description": _("""Proof of concept implementation of add-on update feature (NVDA Core issue 3208)"""), # version - "addon_version": "24.2.0", + "addon_version": "24.2.1", # Author(s) "addon_author": "Joseph Lee , Luke Davis ", # URL for the add-on documentation support diff --git a/readme.md b/readme.md index 910f5a4..2030481 100644 --- a/readme.md +++ b/readme.md @@ -43,6 +43,10 @@ The available add-on update sources are: * Spanish community add-ons catalog * Catalogs maintained by NVDA communities in China and Taiwan +## 24.2.1 + +* Fixes a problem wherein Updater's updates, which appear in the external channel, were shown as still updatable in the store via the stable (or other) channel. Caused by residual JSON files from old non-external installations. Now they are removed. + ## Version 24.2.0 * Release compatible with NVDA 2024.1. From d3058736c31a44397d59aa81ab200b4e52f4182e Mon Sep 17 00:00:00 2001 From: Luke Davis Date: Wed, 3 Apr 2024 07:38:47 -0400 Subject: [PATCH 2/3] Lower update interval to 6 hours --- addon/globalPlugins/addonUpdater/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/globalPlugins/addonUpdater/__init__.py b/addon/globalPlugins/addonUpdater/__init__.py index c30fcb7..e400b17 100644 --- a/addon/globalPlugins/addonUpdater/__init__.py +++ b/addon/globalPlugins/addonUpdater/__init__.py @@ -28,7 +28,7 @@ # Overall update check routine was inspired by StationPlaylist Studio add-on (Joseph Lee).) -addonUpdateCheckInterval = 86400 +addonUpdateCheckInterval = 21600 # 6 hours; was 86400 (24 hours) updateChecker = None From 1974a4f1566f6756534595f476d67b43aa0ff8db Mon Sep 17 00:00:00 2001 From: Luke Davis Date: Fri, 5 Apr 2024 21:34:11 -0400 Subject: [PATCH 3/3] Release update interval lowering change. --- buildVars.py | 2 +- readme.md | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/buildVars.py b/buildVars.py index 7b297c1..8e122cf 100644 --- a/buildVars.py +++ b/buildVars.py @@ -25,7 +25,7 @@ def _(arg): # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description": _("""Proof of concept implementation of add-on update feature (NVDA Core issue 3208)"""), # version - "addon_version": "24.2.1", + "addon_version": "24.2.2", # Author(s) "addon_author": "Joseph Lee , Luke Davis ", # URL for the add-on documentation support diff --git a/readme.md b/readme.md index 2030481..5f1cd66 100644 --- a/readme.md +++ b/readme.md @@ -43,7 +43,11 @@ The available add-on update sources are: * Spanish community add-ons catalog * Catalogs maintained by NVDA communities in China and Taiwan -## 24.2.1 +## Version 24.2.2 + +* Lower update interval to six hours. + +## Version 24.2.1 * Fixes a problem wherein Updater's updates, which appear in the external channel, were shown as still updatable in the store via the stable (or other) channel. Caused by residual JSON files from old non-external installations. Now they are removed.