Reputation: 4689
I have a caching engine that checks for a file's last mod time.
The engine has been working great, but recently my tests started to fail with one specific file.
The getmtime()
function (or stat.st_mtime) both return zero even though the file exists and has a last modified time. All other fails in the folder return expected float epoch time values corresponding to the last mod datetime.
Any ideas on what might be the cause? The documentation does not mention anything about zero return values, only that it returns a float. What would cause python to return 0.0?
Given an existing filepath
(see properties below):
>>> os.path.exists(filepath)
True
>>> os.path.getmtime(cache_filepath)
0.0
>>> os.stat(filepath)
os.stat_result(st_mode=33206, st_ino=1125899907202573, st_dev=2898260115, st_nlink=1, st_uid=0, st_gid=0, st_size=36, st_atime=0, st_mtime=0, st_ctime=1508902786)
>>> os.stat(filepath).st_time
0.0
Upvotes: 3
Views: 460
Reputation: 4689
My mistake - The File in question is in fact set to 0.0 mtime:
PS: Side note - the reason I got into this was because datetime.fromtimestamp
was failing whenever it got a 0.0 value, and it turns out that is Python 3 bug:
https://bugs.python.org/issue29097
Upvotes: 3