From: Daira Hopwood Date: Tue, 11 Aug 2015 15:02:25 +0000 (+0100) Subject: Extend get_pathinfo to add size, ctime and mtime. X-Git-Url: https://git.rkrishnan.org/pf/module-simplejson.html?a=commitdiff_plain;h=4f7c02c651b7bbdad68f00596b219638eecf152e;p=tahoe-lafs%2Ftahoe-lafs.git Extend get_pathinfo to add size, ctime and mtime. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index cd423c58..97ef09b7 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -625,7 +625,7 @@ else: reraise(ConflictError) -PathInfo = namedtuple('PathInfo', 'isdir isfile islink exists') +PathInfo = namedtuple('PathInfo', 'isdir isfile islink exists size ctime mtime') def get_pathinfo(path_u): try: @@ -634,11 +634,19 @@ def get_pathinfo(path_u): return PathInfo(isdir =stat.S_ISDIR(mode), isfile=stat.S_ISREG(mode), islink=stat.S_ISLNK(mode), - exists=True) + exists=True, + size =statinfo.st_size, + ctime =statinfo.st_ctime, + mtime =statinfo.st_mtime, + ) except OSError as e: if e.errno == ENOENT: return PathInfo(isdir=False, isfile=False, islink=False, - exists=False) + exists=False, + size =None, + ctime =None, + mtime =None, + ) raise