Skip to content

Commit

Permalink
Attempt to remove old store record when updating.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Davis authored and Luke Davis committed Mar 21, 2024
1 parent 32296da commit f75c1c8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
25 changes: 22 additions & 3 deletions addon/globalPlugins/addonUpdater/addonUpdateProc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <joseph.lee22590@gmail.com>, Luke Davis <XLTechie@newanswertech.com>",
# URL for the add-on documentation support
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f75c1c8

Please sign in to comment.