fix(core): Remove old directory state logic

- Remove code forcing the exclusion of `.` directories by default, the
  new default exclusion filters do this by default
- Change default state code to always return a value
This commit is contained in:
Andrew Senetar 2023-02-27 17:58:15 -06:00
parent e41c91623c
commit 6d8b86b7eb
Signed by: arsenetar
GPG Key ID: C63300DCE48AB2F1
2 changed files with 4 additions and 2 deletions

View File

@ -84,10 +84,11 @@ class Directories:
for denied_path_re in self._exclude_list.compiled: for denied_path_re in self._exclude_list.compiled:
if denied_path_re.match(str(path.name)): if denied_path_re.match(str(path.name)):
return DirectoryState.EXCLUDED return DirectoryState.EXCLUDED
# return # We still use the old logic to force state on hidden dirs return DirectoryState.NORMAL
# Override this in subclasses to specify the state of some special folders. # Override this in subclasses to specify the state of some special folders.
if path.name.startswith("."): if path.name.startswith("."):
return DirectoryState.EXCLUDED return DirectoryState.EXCLUDED
return DirectoryState.NORMAL
def _get_files(self, from_path, fileclasses, j): def _get_files(self, from_path, fileclasses, j):
try: try:
@ -214,7 +215,7 @@ class Directories:
# direct match? easy result. # direct match? easy result.
if path in self.states: if path in self.states:
return self.states[path] return self.states[path]
state = self._default_state_for_path(path) or DirectoryState.NORMAL state = self._default_state_for_path(path)
# Save non-default states in cache, necessary for _get_files() # Save non-default states in cache, necessary for _get_files()
if state != DirectoryState.NORMAL: if state != DirectoryState.NORMAL:
self.states[path] = state self.states[path] = state

View File

@ -326,6 +326,7 @@ def test_default_path_state_override(tmpdir):
def _default_state_for_path(self, path): def _default_state_for_path(self, path):
if "foobar" in path.parts: if "foobar" in path.parts:
return DirectoryState.EXCLUDED return DirectoryState.EXCLUDED
return DirectoryState.NORMAL
d = MyDirectories() d = MyDirectories()
p1 = Path(str(tmpdir)) p1 = Path(str(tmpdir))