Skip to content

Commit ce459ac

Browse files
committed
Remove the logic of deleting cache.
Now, the cache hash will be regenerated by the mirror server API endpoint, which is the most recommended approach.
1 parent 7ef72dc commit ce459ac

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

addon/globalPlugins/updateMirror.py

+1-29
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
# Copyright 2022-2023 Cary-Rowen <[email protected]>, zh-yx <[email protected]>
33
# released under GPL.
44

5-
import json
6-
import os.path
7-
import shutil
8-
95
import globalPluginHandler
10-
import NVDAState
116
import updateCheck
127
import versionInfo
138
from logHandler import log
@@ -16,28 +11,8 @@
1611
MIRROR_STORE_URL: str = "https://addonstore.nvaccess.mirror.nvdadr.com"
1712
REQUIRED_PRIVATE_API_VERSION: tuple = (2023, 2)
1813
REQUIRED_API_VERSION: tuple = (2024, 1)
19-
2014
CURRENT_API_VERSION: tuple = (versionInfo.version_year, versionInfo.version_major)
21-
JSON_FILE_PATH: str = os.path.join(NVDAState.WritePaths.addonStoreDir, "_cachedCompatibleAddons.json")
22-
23-
24-
def deleteAddonStoreCache(check_mirror: bool = True) -> None:
25-
if os.path.exists(JSON_FILE_PATH):
26-
try:
27-
if check_mirror:
28-
with open(JSON_FILE_PATH, 'r') as json_file:
29-
data = json.load(json_file)
30-
if "data" in data:
31-
data = json.loads(data["data"])
32-
url = data[0]["URL"]
33-
if isinstance(url, str) and "https://github.mirror.nvdadr.com" in url:
34-
return
35-
log.info("Delete old add-on store cache.")
36-
shutil.rmtree(NVDAState.WritePaths.addonStoreDir)
37-
except Exception as e:
38-
log.error(f"Add-on store cache deletion failed: {e}")
39-
40-
15+
4116
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
4217
def __init__(self):
4318
super().__init__()
@@ -60,7 +35,6 @@ def swapNetworkBaseURL(self, URL: str) -> str:
6035
from _addonStore import dataManager, network
6136
originalURL = network._BASE_URL
6237
network._BASE_URL = URL
63-
deleteAddonStoreCache()
6438
dataManager.initialize()
6539
return originalURL
6640

@@ -70,5 +44,3 @@ def terminate(self):
7044
if CURRENT_API_VERSION >= REQUIRED_PRIVATE_API_VERSION:
7145
log.info(f"Restore the Add-on store URL to: {self.original_BASE_URL}")
7246
self.swapNetworkBaseURL(self.original_BASE_URL)
73-
# Delete mirror cache
74-
deleteAddonStoreCache(check_mirror=False)

buildVars.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _(arg):
2525
"addon_description": _("""This update mirror source is provided for NVDA Chinese community users.
2626
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."""),
2727
# version
28-
"addon_version": "0.7.0",
28+
"addon_version": "0.7.1",
2929
# Author(s)
3030
"addon_author": "zh-yx, Cary-rowen, hwf1324 <[email protected]>",
3131
# URL for the add-on documentation support

0 commit comments

Comments
 (0)