-
Bug
-
Resolution: Fixed
-
Neutral
-
5.5.6
-
None
-
Windows 10
-
-
Empty show more show less
-
Yes
-
Kromeriz 119
-
2
When working with light modules there are many directories watched which are not relevant.
This results in heavy DirectoryWatcher activity when doing git fetch or npm install.
So I extended the exclusion property:
magnolia.resources.filesystem.observation.excludedDirectories=META-INF,WEB-INF,cache,docroot,logs,repositories,tmp,.git,.idea,node_modules
The exclusions are applied, but are not matched by ExclusionsFilter if in subdirectories.
Simple test case:
public class ExclusionFilterTest { private Path rootPath; private ExclusionsFilter filter; @Before public void setup() { this.rootPath = Paths.get("C:/magnolia-resources-root"); final List<String> configuredExcludedDirectories = Lists.newArrayList(); configuredExcludedDirectories.add(".git"); this.filter = new ExclusionsFilter(rootPath, configuredExcludedDirectories, Collections.emptyList(), Collections.emptyList()); } @Test public void shouldNotAcceptExcludedDirectoryInRootPath() { final Path path = rootPath.resolve(".git"); assertFalse("Should match .git in root", filter.apply(path)); } @Test public void shouldNotAcceptExcludedDirectoryInSubPath() { final Path path = rootPath.resolve("light-module/.git"); assertFalse("Should match .git in subdir", filter.apply(path)); } }
The second test fails on Windows because of the regex used in ExclusionsFilter.
The relevant code:
info.magnolia.resourceloader.file.ExclusionsFilter#apply
// This resolves to "light-module\.git" - notice the backslash
Path rel = rootPath.relativize(normalizedDir);
This does not match the regex
(^|.*/)\Q.git\E($|/.*)
.
It works if I modify the regex to
(^|.*[/\\])\Q.git\E($|[/\\].*)
Acceptance criteria