mirror of https://gitlab.com/bashrc2/epicyon
Don't write time to file if it hasn't changed
parent
e1123279c8
commit
f94f6eb997
7
inbox.py
7
inbox.py
|
@ -2088,6 +2088,13 @@ def updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
|
|||
lastSeenFilename = lastSeenPath + '/' + actor.replace('/', '#') + '.txt'
|
||||
currTime = datetime.datetime.utcnow()
|
||||
daysSinceEpoch = (currTime - datetime.datetime(1970, 1, 1)).days
|
||||
# has the value changed?
|
||||
if os.path.isfile(lastSeenFilename):
|
||||
with open(lastSeenFilename, 'r') as lastSeenFile:
|
||||
daysSinceEpochFile = lastSeenFile.read()
|
||||
if int(daysSinceEpochFile) == daysSinceEpoch:
|
||||
# value hasn't changed, so we can save writing anything to file
|
||||
return
|
||||
with open(lastSeenFilename, 'w+') as lastSeenFile:
|
||||
lastSeenFile.write(str(daysSinceEpoch))
|
||||
|
||||
|
|
Loading…
Reference in New Issue