Skip to content

Commit b1c1ef4

Browse files
authored
Merge 8f06a91 into e8bf6c2
2 parents e8bf6c2 + 8f06a91 commit b1c1ef4

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

source/updateCheck.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# A part of NonVisual Desktop Access (NVDA)
22
# This file is covered by the GNU General Public License.
33
# See the file COPYING for more details.
4-
# Copyright (C) 2012-2021 NV Access Limited, Zahari Yurukov, Babbage B.V., Joseph Lee
4+
# Copyright (C) 2012-2023 NV Access Limited, Zahari Yurukov, Babbage B.V., Joseph Lee
55

66
"""Update checking functionality.
77
@note: This module may raise C{RuntimeError} on import if update checking for this build is not supported.
88
"""
9-
from typing import Dict, Optional, Tuple
9+
from typing import (
10+
Any,
11+
Dict,
12+
Optional,
13+
Tuple,
14+
)
1015
import garbageHandler
1116
import globalVars
1217
import config
@@ -68,12 +73,12 @@
6873
log.debugWarning("Default download path for updates %s could not be created."%storeUpdatesDir)
6974

7075
#: Persistent state information.
71-
#: @type: dict
72-
state = None
73-
_stateFileName = None
76+
state: Optional[Dict[str, Any]] = None
77+
_stateFilename: Optional[str] = None
7478
#: The single instance of L{AutoUpdateChecker} if automatic update checking is enabled,
7579
#: C{None} if it is disabled.
76-
autoChecker = None
80+
autoChecker: Optional["AutoUpdateChecker"] = None
81+
7782

7883
def getQualifiedDriverClassNameForStats(cls):
7984
""" fetches the name from a given synthDriver or brailleDisplay class, and appends core for in-built code, the add-on name for code from an add-on, or external for code in the NVDA user profile.
@@ -250,6 +255,7 @@ def check(self):
250255

251256
def _bg(self):
252257
try:
258+
assert state is not None
253259
info = checkForUpdate(self.AUTO)
254260
except:
255261
log.debugWarning("Error checking for update", exc_info=True)
@@ -798,6 +804,9 @@ def initialize():
798804
state = pickle.load(f)
799805
except:
800806
log.debugWarning("Couldn't retrieve update state", exc_info=True)
807+
state = None
808+
809+
if state is None:
801810
# Defaults.
802811
state = {
803812
"lastCheck": 0,
@@ -807,7 +816,10 @@ def initialize():
807816

808817
# check the pending version against the current version
809818
# and make sure that pendingUpdateFile and pendingUpdateVersion are part of the state dictionary.
810-
if "pendingUpdateVersion" not in state or state["pendingUpdateVersion"] == versionInfo.version:
819+
if (
820+
"pendingUpdateVersion" not in state
821+
or state["pendingUpdateVersion"] == versionInfo.version
822+
):
811823
_setStateToNone(state)
812824
# remove all update files except the one that is currently pending (if any)
813825
try:

0 commit comments

Comments
 (0)