Skip to content

Commit d20029b

Browse files
committed
Delete add-on store cache when installing and uninstalling add-ons.
1 parent 7c7f400 commit d20029b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

addon/installTasks.py

+26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
11
import addonHandler
2+
import os
3+
import shutil
4+
import globalVars
5+
import json
6+
from logHandler import log
7+
8+
json_file_path = os.path.join(globalVars.appArgs.configPath, "addonStore", "_cachedCompatibleAddons.json")
9+
def deleteAddonStoreCache():
10+
try:
11+
with open(json_file_path, 'r') as json_file:
12+
data = json.load(json_file)
13+
if "data" in data:
14+
data = json.loads(data["data"])
15+
url = data[0]["URL"]
16+
if isinstance(url, str) and "https://github.mirror.nvdadr.com" not in url:
17+
shutil.rmtree(os.path.dirname(json_file_path))
18+
except Exception as e:
19+
log.error(f"Add-on store cache deletion failed: {e}")
220

321
def onInstall():
22+
deleteAddonStoreCache()
423
for addon in addonHandler.getAvailableAddons():
524
if addon.name == "viyfMirror":
625
addon.requestRemove()
726
break
27+
28+
def onUninstall():
29+
# Delete mirror cache
30+
try:
31+
shutil.rmtree(os.path.dirname(json_file_path))
32+
except Exception as e:
33+
log.error(f"Add-on store cache deletion failed: {e}")

buildVars.py

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

0 commit comments

Comments
 (0)