From ea525ea1f6bfed8eafbe951cde9725623dd5b7c4 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Mon, 31 Jan 2011 17:43:23 +0300 Subject: [PATCH] Fix listDirectory for symlink to directory. --- pym/cl_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 98ffec5..db65b48 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -770,8 +770,10 @@ def getFilesCount(directory): def listDirectory(directory): """Get files from directory, if it exists""" if os.path.exists(directory) and \ - stat.S_ISDIR(os.lstat(directory)[stat.ST_MODE]) and \ - os.access(directory,os.R_OK): + os.access(directory,os.R_OK) and \ + (stat.S_ISDIR(os.lstat(directory)[stat.ST_MODE]) or + (stat.S_ISLNK(os.lstat(directory)[stat.ST_MODE]) and + stat.S_ISDIR(os.lstat(os.readlink(directory))[stat.ST_MODE]))): return os.listdir(directory) else: return []