Do not fail in last_modified if file is absent
* wcs/qommon/storage.py: in last_modified generic implementations do not fail when stat fails (usually because the file/directory does not exist), instead return current time.
This commit is contained in:
parent
b0467928df
commit
91c74810f2
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import time
|
||||
import pickle
|
||||
|
||||
from quixote import get_publisher
|
||||
|
@ -332,11 +333,21 @@ class StorableObject(object):
|
|||
|
||||
def last_modified_id(cls, id):
|
||||
filename = os.path.join(cls.get_objects_dir(), fix_key(id))
|
||||
mtime = 0
|
||||
try:
|
||||
stat = os.stat(filename)
|
||||
return stat.st_mtime
|
||||
mtime = stat.st_mtime
|
||||
except OSError:
|
||||
mtime = int(time.time())
|
||||
return mtime
|
||||
last_modified_id = classmethod(last_modified_id)
|
||||
|
||||
def last_modified(cls):
|
||||
mtime = 0
|
||||
try:
|
||||
stat = os.stat(cls.get_objects_dir())
|
||||
return stat.st_mtime
|
||||
mtime = stat.st_mtime
|
||||
except OSError:
|
||||
mtime = int(time.time())
|
||||
return mtime
|
||||
last_modified = classmethod(last_modified)
|
||||
|
|
Loading…
Reference in New Issue