Rev3176, Skip listing ignored directories on signing
This commit is contained in:
parent
adbf787bd4
commit
c7d067ea3c
3 changed files with 25 additions and 7 deletions
|
@ -10,7 +10,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.6.0"
|
||||
self.rev = 3175
|
||||
self.rev = 3176
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.config_file = "zeronet.conf"
|
||||
|
|
|
@ -512,14 +512,12 @@ class ContentManager(object):
|
|||
ignored = True
|
||||
self.log.error("- [ERROR] Only ascii encoded directories allowed: %s" % dir_inner_path)
|
||||
|
||||
for file_relative_path in self.site.storage.walk(dir_inner_path):
|
||||
for file_relative_path in self.site.storage.walk(dir_inner_path, ignore_pattern):
|
||||
file_name = helper.getFilename(file_relative_path)
|
||||
|
||||
ignored = optional = False
|
||||
if file_name == "content.json":
|
||||
ignored = True
|
||||
elif ignore_pattern and SafeRe.match(ignore_pattern, file_relative_path):
|
||||
ignored = True
|
||||
elif file_name.startswith(".") or file_name.endswith("-old") or file_name.endswith("-new"):
|
||||
ignored = True
|
||||
elif not self.isValidRelativePath(file_relative_path):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue