diff --git a/skel_common/readme_changelog.txt b/skel_common/readme_changelog.txt index e1b3302..443ca6a 100644 --- a/skel_common/readme_changelog.txt +++ b/skel_common/readme_changelog.txt @@ -8,7 +8,10 @@ Changelog - Changed FTLDat to allow opening dats in read-only mode - Changed modman.exe to fail rather than use VirtualStore - Added modman_admin.exe, which always runs as administrator -- Added a Validate warning for junk files whose names end with a tilde +- Added a Validate warning for junk files whose names start/end with tilde +- Added a Validate warning for junk files whose names start+end with hash +- Added a Validate warning for junk files named '.dropbox' +- Added a check during patching to skip junk files - Added an error popup when the jar is double-clicked - Minor optimizations to reduce memory usage diff --git a/src/main/java/net/vhati/modmanager/core/ModPatchThread.java b/src/main/java/net/vhati/modmanager/core/ModPatchThread.java index 2331691..7e2f0ea 100644 --- a/src/main/java/net/vhati/modmanager/core/ModPatchThread.java +++ b/src/main/java/net/vhati/modmanager/core/ModPatchThread.java @@ -222,6 +222,12 @@ public class ModPatchThread extends Thread { continue; } + if ( ModUtilities.isJunkFile( innerPath ) ) { + log.warn( String.format( "Skipping junk file: %s", innerPath ) ); + zis.closeEntry(); + continue; + } + if ( fileName.endsWith( ".xml.append" ) || fileName.endsWith( ".append.xml" ) ) { innerPath = parentPath + fileName.replaceAll( "[.](?:xml[.]append|append[.]xml)$", ".xml" ); innerPath = checkCase( innerPath, knownPaths, knownPathsLower ); diff --git a/src/main/java/net/vhati/modmanager/core/ModUtilities.java b/src/main/java/net/vhati/modmanager/core/ModUtilities.java index 649c7b8..c65899c 100644 --- a/src/main/java/net/vhati/modmanager/core/ModUtilities.java +++ b/src/main/java/net/vhati/modmanager/core/ModUtilities.java @@ -48,6 +48,8 @@ public class ModUtilities { private static final Logger log = LogManager.getLogger(ModUtilities.class); + private static Pattern junkFilePtn = Pattern.compile( "[.]DS_Store$|(?:^|/)thumbs[.]db$|(?:^|/)[.]dropbox$|(?:^|/)~|~$|(?:^|/)#.+#$" ); + /** * Encodes a string (throwing an exception on bad chars) to bytes in a stream. @@ -325,6 +327,24 @@ public class ModUtilities { } + /** + * Returns true if a path matches known junk files, false otherwise. + * + * This includes: + * *.DS_Store + * thumbs.db + * .dropbox + * #*# + * ~* + * *~ + * + * @param innerPath a path with forward slashes + */ + public static boolean isJunkFile( String innerPath ) { + return junkFilePtn.matcher(innerPath).find(); + } + + /** * Checks a mod file for common problems. * @@ -337,8 +357,6 @@ public class ModUtilities { boolean modValid = true; boolean seenAppend = false; - Pattern junkFilePtn = Pattern.compile( "[.]DS_Store$|^thumbs[.]db$|~$" ); - Pattern validRootDirPtn = Pattern.compile( "^(?:audio|data|fonts|img|mod-appendix)/" ); List seenJunkDirs = new ArrayList(); @@ -389,7 +407,7 @@ public class ModUtilities { } else if ( item.isDirectory() ) { } - else if ( junkFilePtn.matcher(innerPath).find() ) { + else if ( isJunkFile( innerPath ) ) { pendingMsgs.add( new ReportMessage( ReportMessage.ERROR, String.format( "Junk file" )