1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 02:19:14 +00:00

feature for #458

This commit is contained in:
deadc0de6
2025-05-14 15:57:53 +02:00
parent 1bd00b33a7
commit 8dc1af6cd2
6 changed files with 137 additions and 20 deletions

View File

@@ -18,10 +18,11 @@ class FTreeDir:
directory tree for comparison
"""
def __init__(self, path, ignores=None, debug=False):
def __init__(self, path, ignores=None, debug=False, handle_dir_as_block=False):
self.path = path
self.ignores = ignores
self.debug = debug
self.handle_dir_as_block = handle_dir_as_block
self.entries = []
self.log = Logger(debug=self.debug)
if os.path.exists(path) and os.path.isdir(path):
@@ -33,6 +34,12 @@ class FTreeDir:
ignore empty directory
test for ignore pattern
"""
# if directory should be handled as a block, just add the directory itself
if self.handle_dir_as_block:
self.log.dbg(f'handle as block: {self.path}')
self.entries.append(self.path)
return
for root, dirs, files in os.walk(self.path, followlinks=True):
for file in files:
fpath = os.path.join(root, file)