forked from viyf/NVDAUpdateMirror
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now, the cache hash will be regenerated by the mirror server API endpoint, which is the most recommended approach.
- Loading branch information
1 parent
7ef72dc
commit ce459ac
Showing
2 changed files
with
2 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,7 @@ | |
# Copyright 2022-2023 Cary-Rowen <[email protected]>, zh-yx <[email protected]> | ||
# released under GPL. | ||
|
||
import json | ||
import os.path | ||
import shutil | ||
|
||
import globalPluginHandler | ||
import NVDAState | ||
import updateCheck | ||
import versionInfo | ||
from logHandler import log | ||
|
@@ -16,28 +11,8 @@ | |
MIRROR_STORE_URL: str = "https://addonstore.nvaccess.mirror.nvdadr.com" | ||
REQUIRED_PRIVATE_API_VERSION: tuple = (2023, 2) | ||
REQUIRED_API_VERSION: tuple = (2024, 1) | ||
|
||
CURRENT_API_VERSION: tuple = (versionInfo.version_year, versionInfo.version_major) | ||
JSON_FILE_PATH: str = os.path.join(NVDAState.WritePaths.addonStoreDir, "_cachedCompatibleAddons.json") | ||
|
||
|
||
def deleteAddonStoreCache(check_mirror: bool = True) -> None: | ||
if os.path.exists(JSON_FILE_PATH): | ||
try: | ||
if check_mirror: | ||
with open(JSON_FILE_PATH, 'r') as json_file: | ||
data = json.load(json_file) | ||
if "data" in data: | ||
data = json.loads(data["data"]) | ||
url = data[0]["URL"] | ||
if isinstance(url, str) and "https://github.mirror.nvdadr.com" in url: | ||
return | ||
log.info("Delete old add-on store cache.") | ||
shutil.rmtree(NVDAState.WritePaths.addonStoreDir) | ||
except Exception as e: | ||
log.error(f"Add-on store cache deletion failed: {e}") | ||
|
||
|
||
|
||
class GlobalPlugin(globalPluginHandler.GlobalPlugin): | ||
def __init__(self): | ||
super().__init__() | ||
|
@@ -60,7 +35,6 @@ def swapNetworkBaseURL(self, URL: str) -> str: | |
from _addonStore import dataManager, network | ||
originalURL = network._BASE_URL | ||
network._BASE_URL = URL | ||
deleteAddonStoreCache() | ||
dataManager.initialize() | ||
return originalURL | ||
|
||
|
@@ -70,5 +44,3 @@ def terminate(self): | |
if CURRENT_API_VERSION >= REQUIRED_PRIVATE_API_VERSION: | ||
log.info(f"Restore the Add-on store URL to: {self.original_BASE_URL}") | ||
self.swapNetworkBaseURL(self.original_BASE_URL) | ||
# Delete mirror cache | ||
deleteAddonStoreCache(check_mirror=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ def _(arg): | |
"addon_description": _("""This update mirror source is provided for NVDA Chinese community users. | ||
It can enhance the update speed of NVDA, improve the search and download speed of the add-on store, and resolve issues where certain network operators are unable to download add-ons from the add-on store, thus effectively improving user experience."""), | ||
# version | ||
"addon_version": "0.7.0", | ||
"addon_version": "0.7.1", | ||
# Author(s) | ||
"addon_author": "zh-yx, Cary-rowen, hwf1324 <[email protected]>", | ||
# URL for the add-on documentation support | ||
|