Skip to content

Commit a706720

Browse files
committed
The previous variant didn't seem to work on Linux.
1 parent 62b0807 commit a706720

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/idpyoidc/storage/listfile.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
from pathlib import Path
34
import time
45

56
from filelock import FileLock
@@ -18,7 +19,6 @@ def __init__(self, file_name):
1819
fp = open(file_name, "x")
1920
fp.close()
2021

21-
2222
def __getitem__(self, item):
2323
if self.is_changed(self.file_name):
2424
self.lst = self._read_info(self.file_name)
@@ -41,12 +41,16 @@ def get_mtime(fname):
4141
:return: The last time the file was modified.
4242
"""
4343
try:
44-
mtime = os.stat(fname).st_mtime_ns
44+
target = Path(fname)
45+
mtime = target.stat().st_mtime
46+
# mtime = os.stat(fname).st_mtime_ns
4547
except OSError:
46-
# The file might be right in the middle of being written
48+
# The file might be right in the middle of being written to
4749
# so sleep
4850
time.sleep(1)
49-
mtime = os.stat(fname).st_mtime_ns
51+
target = Path(fname)
52+
mtime = target.stat().st_mtime
53+
# mtime = os.stat(fname).st_mtime_ns
5054

5155
return mtime
5256

0 commit comments

Comments
 (0)