Skip to content

Commit 33b8070

Browse files
committed
Weird filesystem behavor regarding mtime
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 9a0f7f0 commit 33b8070

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/cryptojwt/key_bundle.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def __init__(
201201
self.imp_jwks = None
202202
self.last_updated = 0
203203
self.last_remote = None # HTTP Date of last remote update
204-
self.last_local = None # UNIX timestamp of last local update
204+
self._last_local = None # UNIX timestamp of last local update
205205

206206
if httpc:
207207
self.httpc = httpc
@@ -224,6 +224,21 @@ def __init__(
224224
if self.local:
225225
self._do_local(kid)
226226

227+
@property
228+
def last_local(self):
229+
return self._last_local
230+
231+
@last_local.setter
232+
def last_local(self, value):
233+
import sys
234+
from traceback import print_stack
235+
236+
print_stack(limit=8, file=sys.stdout)
237+
print("sssssssssssssssssssssssssssssssss")
238+
print("setting last_local to:", value)
239+
print("sssssssssssssssssssssssssssssssss")
240+
self._last_local = value
241+
227242
def _set_source(self, source, fileformat):
228243
if source.startswith("file://"):
229244
self.source = source[7:]
@@ -251,6 +266,12 @@ def _do_local(self, kid):
251266

252267
def _local_update_required(self) -> bool:
253268
stat = os.stat(self.source)
269+
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
270+
print("mtime:", stat.st_mtime)
271+
print("last_local:", self.last_local)
272+
if self.last_local:
273+
print("mtime < last_local", stat.st_mtime < self.last_local)
274+
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
254275
if self.last_local and stat.st_mtime < self.last_local:
255276
LOGGER.debug("%s not modfied", self.source)
256277
return False
@@ -484,13 +505,10 @@ def update(self):
484505
updated = (
485506
self.do_remote()
486507
if self.remote
487-
488508
else self.do_local_jwk(self.source)
489509
if self.local and self.fileformat in ["jwks", "jwk"]
490-
491510
else self.do_local_der(self.source, self.keytype, self.keyusage)
492511
if self.local and self.fileformat in ["der"]
493-
494512
else False
495513
)
496514
except Exception as err:

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ envlist = py{36,37,38},quality
44
[testenv]
55
passenv = CI TRAVIS TRAVIS_*
66
commands =
7-
py.test --cov=cryptojwt --isort --black {posargs}
7+
pytest -vvv -ra -s --cov=cryptojwt --isort --black {posargs}
88
codecov
99
extras = testing
1010
deps =

0 commit comments

Comments
 (0)