From 147397d63461bac88651bd451b04e6c4ff46f26b Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 11 Aug 2015 16:02:25 +0100 Subject: [PATCH] Extend get_pathinfo to add size, ctime and mtime. Signed-off-by: Daira Hopwood --- src/allmydata/util/fileutil.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 -- 2.45.2