Skip to content

Commit f3df576

Browse files
committed
Caller has a much simpler pattern to handle read errors
1 parent cd27d20 commit f3df576

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

msal_extensions/token_cache.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
import os
33
import warnings
44
import time
5-
import errno
65
import logging
76

87
import msal
98

109
from .cache_lock import CrossPlatLock
1110
from .persistence import (
12-
_mkdir_p, FilePersistence,
11+
_mkdir_p, PersistenceNotFound, FilePersistence,
1312
FilePersistenceWithDataProtection, KeychainPersistence)
1413

1514

@@ -35,10 +34,10 @@ def _reload_if_necessary(self):
3534
if self._last_sync < self._persistence.time_last_modified():
3635
self.deserialize(self._persistence.load())
3736
self._last_sync = time.time()
38-
except IOError as exp:
39-
if exp.errno != errno.ENOENT:
40-
raise
41-
# Otherwise, from cache's perspective, a nonexistent file is a NO-OP
37+
except PersistenceNotFound:
38+
# From cache's perspective, a nonexistent persistence is a NO-OP.
39+
pass
40+
# However, existing data unable to be decrypted will still be bubbled up.
4241

4342
def modify(self, credential_type, old_entry, new_key_value_pairs=None):
4443
with CrossPlatLock(self._lock_location):

0 commit comments

Comments
 (0)