Rev3176, Skip listing ignored directories on signing

This commit is contained in:
shortcutme 2017-12-20 23:25:25 +01:00
parent adbf787bd4
commit c7d067ea3c
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
3 changed files with 25 additions and 7 deletions

View file

@ -232,16 +232,36 @@ class SiteStorage(object):
raise err
# List files from a directory
def walk(self, dir_inner_path):
def walk(self, dir_inner_path, ignore=None):
directory = self.getPath(dir_inner_path)
for root, dirs, files in os.walk(directory):
root = root.replace("\\", "/")
root_relative_path = re.sub("^%s" % re.escape(directory), "", root).lstrip("/")
for file_name in files:
if root_relative_path: # Not root dir
yield root_relative_path + "/" + file_name
file_relative_path = root_relative_path + "/" + file_name
else:
yield file_name
file_relative_path = file_name
if ignore and SafeRe.match(ignore, file_relative_path):
continue
yield file_relative_path
# Don't scan directory that is in the ignore pattern
if ignore:
dirs_filtered = []
for dir_name in dirs:
if root_relative_path:
dir_relative_path = root_relative_path + "/" + dir_name
else:
dir_relative_path = dir_name
if ignore == ".*" or re.match(".*([|(]|^)%s([|)]|$)" % re.escape(dir_relative_path + "/.*"), ignore):
continue
dirs_filtered.append(dir_name)
dirs[:] = dirs_filtered
# list directories in a directory
def list(self, dir_inner_path):