mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged WOLF-6 (WOLF.0.0) to 5.1.1 (5.1.1)
122785 mward: UTF-378: fixed path pattern matching on Windows. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/services/full-installer/branches/5.1.1@124010 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -7,24 +7,23 @@
|
||||
*/
|
||||
package org.alfresco.update.tool.dircomp;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
import org.alfresco.update.tool.dircomp.exception.FileTreeCompareException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import de.schlichtherle.truezip.file.TArchiveDetector;
|
||||
import de.schlichtherle.truezip.file.TConfig;
|
||||
import de.schlichtherle.truezip.file.TFile;
|
||||
import de.schlichtherle.truezip.file.TVFS;
|
||||
import de.schlichtherle.truezip.fs.archive.zip.ZipDriver;
|
||||
import de.schlichtherle.truezip.socket.sl.IOPoolLocator;
|
||||
import org.alfresco.update.tool.dircomp.exception.FileTreeCompareException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class capable of comparing two trees of files to determine which directories or
|
||||
* files appear in one tree and not the other, or whether a file that appears in
|
||||
@@ -53,34 +52,39 @@ public class FileTreeCompareImpl implements FileTreeCompare
|
||||
{
|
||||
// Add default ignores
|
||||
ignorePaths = new HashSet<>();
|
||||
ignorePaths.add("alf_data/postgresql/**");
|
||||
ignorePaths.add("META-INF/MANIFEST.MF");
|
||||
ignorePaths.add("META-INF/maven/**");
|
||||
ignorePaths.add("README.txt");
|
||||
ignorePaths.add("uninstall.app/**");
|
||||
ignorePaths.add(toPlatformPath("alf_data/postgresql/**"));
|
||||
ignorePaths.add(toPlatformPath("META-INF/MANIFEST.MF"));
|
||||
ignorePaths.add(toPlatformPath("META-INF/maven/**"));
|
||||
ignorePaths.add(toPlatformPath("README.txt"));
|
||||
ignorePaths.add(toPlatformPath("uninstall.app/**"));
|
||||
}
|
||||
if (allowedDiffsPaths == null)
|
||||
{
|
||||
// Add default paths where certain differences are allowed, e.g. absolute path references.
|
||||
allowedDiffsPaths = new HashSet<>();
|
||||
allowedDiffsPaths.add("common/bin/**");
|
||||
allowedDiffsPaths.add("common/include/**/*.h");
|
||||
allowedDiffsPaths.add("common/lib/**/*.pc");
|
||||
allowedDiffsPaths.add("common/lib/**/*.la");
|
||||
allowedDiffsPaths.add("libreoffice.app/Contents/Resources/bootstraprc");
|
||||
allowedDiffsPaths.add("postgresql/bin/**");
|
||||
allowedDiffsPaths.add("**/*.sh");
|
||||
allowedDiffsPaths.add("**/*.bat");
|
||||
allowedDiffsPaths.add("**/*.ini");
|
||||
allowedDiffsPaths.add("**/*.properties");
|
||||
allowedDiffsPaths.add("**/*.xml");
|
||||
allowedDiffsPaths.add("**/*.sample");
|
||||
allowedDiffsPaths.add("**/*.txt");
|
||||
allowedDiffsPaths.add(toPlatformPath("common/bin/**"));
|
||||
allowedDiffsPaths.add(toPlatformPath("common/include/**/*.h"));
|
||||
allowedDiffsPaths.add(toPlatformPath("common/lib/**/*.pc"));
|
||||
allowedDiffsPaths.add(toPlatformPath("common/lib/**/*.la"));
|
||||
allowedDiffsPaths.add(toPlatformPath("libreoffice.app/Contents/Resources/bootstraprc"));
|
||||
allowedDiffsPaths.add(toPlatformPath("postgresql/bin/**"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.sh"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.bat"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.ini"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.properties"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.xml"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.sample"));
|
||||
allowedDiffsPaths.add(toPlatformPath("**/*.txt"));
|
||||
}
|
||||
this.ignorePaths.addAll(ignorePaths);
|
||||
this.allowedDiffsPaths.addAll(allowedDiffsPaths);
|
||||
}
|
||||
|
||||
|
||||
private String toPlatformPath(String path)
|
||||
{
|
||||
return path.replace("/", File.separator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet compare(Path p1, Path p2)
|
||||
{
|
||||
|
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
public class HtmlResultFormatter implements ResultFormatter
|
||||
{
|
||||
private int maxPathDisplayLength = 80;
|
||||
private int maxPathDisplayLength = 50;
|
||||
private boolean differencesOnly;
|
||||
|
||||
|
||||
|
@@ -133,14 +133,14 @@ public class FileTreeCompareImplTest
|
||||
assertTrue(matcher.match("*.sh", "alfresco.sh"));
|
||||
assertFalse(matcher.match("*.sh", "a/different/alfresco.sh"));
|
||||
|
||||
// What about path separators?
|
||||
// Windows matcher
|
||||
// It seems that changing the path separator on an instance that's already been
|
||||
// used isn't a good idea due to pattern caching.
|
||||
matcher = new AntPathMatcher("\\");
|
||||
assertTrue(matcher.match("**\\common\\lib\\**\\*.pc", "prefix\\common\\lib\\pkgconfig\\ImageMagick++-6.Q16.pc"));
|
||||
assertTrue(matcher.match("\\**\\common\\lib\\**\\*.pc", "\\absolute\\prefix\\common\\lib\\pkgconfig\\ImageMagick++-6.Q16.pc"));
|
||||
|
||||
// Path separator must be set before this will work
|
||||
assertFalse(matcher.match("**/common/lib/**/*.pc", "prefix\\common\\lib\\pkgconfig\\ImageMagick++-6.Q16.pc"));
|
||||
matcher.setPathSeparator("\\");
|
||||
assertTrue(matcher.match("**/common/lib/**/*.pc", "prefix\\common\\lib\\pkgconfig\\ImageMagick++-6.Q16.pc"));
|
||||
assertTrue(matcher.match("b\\blah.txt", "b\\blah.txt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user