8000 tests: better directory collection in pgdata_content · postgrespro/pg_probackup@20667e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20667e9

Browse files
committed
tests: better directory collection in pgdata_content
There is no need to walk pgdata twice. We could delete parent directories instead of skipping them.
1 parent 19a7c5b commit 20667e9

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

tests/helpers/ptrack_helpers.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,27 +1803,13 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
18031803
file_fullpath, size_in_pages
18041804
)
18051805

1806-
for root, dirs, files in os.walk(pgdata, topdown=False, followlinks=True):
1807-
for directory in sorted(dirs):
1806+
for directory in dirs:
18081807
directory_path = os.path.join(root, directory)
18091808
directory_relpath = os.path.relpath(directory_path, pgdata)
1810-
1811-
found = False
1812-
for d in dirs_to_ignore:
1813-
if d in directory_relpath:
1814-
found = True
1815-
break
1816-
1817-
# check if directory already here as part of larger directory
1818-
if not found:
1819-
for d in directory_dict['dirs']:
1820-
# print("OLD dir {0}".format(d))
1821-
if directory_relpath in d:
1822-
found = True
1823-
break
1824-
1825-
if not found:
1826-
directory_dict['dirs'][directory_relpath] = {}
1809+
parent = os.path.dirname(directory_relpath)
1810+
if parent in directory_dict['dirs']:
1811+
del directory_dict['dirs'][parent]
1812+
directory_dict['dirs'][directory_relpath] = {}
18271813

18281814
# get permissions for every file and directory
18291815
for file in directory_dict['dirs']:

0 commit comments

Comments
 (0)
0