Skip to content
Snippets Groups Projects
Commit 62a1fb1b authored by Wei Liu's avatar Wei Liu
Browse files

Fixed: leading & trailing whitespaces in file names were mistakenly

trimmed
parent 2341c0c1
Branches
Tags v0.7.5
No related merge requests found
......@@ -5,7 +5,7 @@
<groupId>au.edu.unimelb.mf</groupId>
<artifactId>unimelb-mf-clients</artifactId>
<version>0.7.4</version>
<version>0.7.5</version>
<packaging>jar</packaging>
<name>unimelb-mf-clients</name>
<url>https://gitlab.unimelb.edu.au/resplat-mediaflux/unimelb-mf-clients</url>
......
......@@ -141,10 +141,10 @@ public class CheckResult {
public final String toCSVRecord() {
return String.format("\"%s:%s\",%s,%s,\"%s:%s\",%s,%s,%s,%s",
srcType().toString().toLowerCase(), srcPath().trim(),
srcType().toString().toLowerCase(), srcPath(),
_srcLength != null ? Long.toString(_srcLength) : "",
_srcChecksum != null ? _srcChecksum : "",
dstType().toString().toLowerCase(), dstPath().trim(),
dstType().toString().toLowerCase(), dstPath(),
_dstLength != null ? Long.toString(_dstLength) : "",
_dstChecksum != null ? _dstChecksum : "",
exists() ? "true" : "false",
......
......@@ -152,14 +152,14 @@ public class DefaultCheckHandler implements CheckHandler {
if (!result.exists()) {
_nbFileMissing.getAndIncrement();
System.out.printf("Missing: %s:%s (source %s:%s)%n", result.dstType().toString().toLowerCase(),
result.dstPath().trim(), result.srcType().toString().toLowerCase(),
result.srcPath().trim());
result.dstPath(), result.srcType().toString().toLowerCase(),
result.srcPath());
} else {
_nbFileContentMismatch.getAndIncrement();
System.out.printf("Content mismatch: %s:%s (source %s:%s)%n",
result.dstType().toString().toLowerCase(),
result.dstPath().trim(), result.srcType().toString().toLowerCase(),
result.srcPath().trim());
result.dstPath(), result.srcType().toString().toLowerCase(),
result.srcPath());
}
result.println(_outputPS);
}
......@@ -175,14 +175,14 @@ public class DefaultCheckHandler implements CheckHandler {
if (!result.exists()) {
_nbAssetMissing.getAndIncrement();
System.out.printf("Missing: %s:%s (source %s:%s)%n", result.dstType().toString().toLowerCase(),
result.dstPath().trim(), result.srcType().toString().toLowerCase(),
result.srcPath().trim());
result.dstPath(), result.srcType().toString().toLowerCase(),
result.srcPath());
} else {
_nbAssetContentMismatch.getAndIncrement();
System.out.printf("Content mismatch: %s:%s (source %s:%s)%n",
result.dstType().toString().toLowerCase(),
result.dstPath().trim(), result.srcType().toString().toLowerCase(),
result.srcPath().trim());
result.dstPath(), result.srcType().toString().toLowerCase(),
result.srcPath());
}
result.println(_outputPS);
}
......
......@@ -161,7 +161,7 @@ public class MFCheck extends MFSyncApp {
throw new IllegalArgumentException("Missing asset namespace path.");
}
String ns = args[i + 1];
if (ns == null || ns.trim().isEmpty()) {
if (ns == null || ns.isEmpty()) {
throw new IllegalArgumentException("Invalid asset namespace: " + ns);
}
if (!ns.startsWith("/")) {
......
......@@ -19,7 +19,7 @@ public class PathUtils {
int n = 0;
for (String path : paths) {
if (path != null) {
path = path.trim().replace(SLASH_CHAR, separator).replace(BACKSLASH_CHAR, separator);
path = path.replace(SLASH_CHAR, separator).replace(BACKSLASH_CHAR, separator);
if (!path.isEmpty()) {
if (n == 0) {
path = trimRight(separator, path);
......@@ -56,7 +56,6 @@ public class PathUtils {
if (path == null || path.isEmpty()) {
return path;
}
path = path.trim();
String s = String.valueOf(c);
while (path.startsWith(s) && !path.equals(s)) {
path = path.substring(s.length());
......@@ -68,7 +67,6 @@ public class PathUtils {
if (path == null || path.isEmpty()) {
return path;
}
path = path.trim();
String s = String.valueOf(c);
while (path.endsWith(s) && !path.equals(s)) {
path = path.substring(0, path.length() - s.length());
......@@ -80,11 +78,10 @@ public class PathUtils {
if (path == null) {
return path;
}
path = path.trim();
if (path.isEmpty()) {
return path;
}
path = path.trim().replace(SLASH_CHAR, File.separatorChar);
path = path.replace(SLASH_CHAR, File.separatorChar);
return trimRight(File.separatorChar, path);
}
......@@ -92,11 +89,9 @@ public class PathUtils {
if (path == null) {
return path;
}
path = path.trim();
if (path.isEmpty()) {
return path;
}
path = path.trim();
if (OSUtils.isWindows()) {
// On Windows, we need to replace backslash with slash. However on other
// platform, backslash is a valid file name character. So we only replace the
......@@ -209,7 +204,7 @@ public class PathUtils {
}
public static String getParentPath(String path) {
if (path == null || path.trim().isEmpty() || path.length() == 1) {
if (path == null || path.isEmpty() || path.length() == 1) {
return null;
}
......@@ -222,7 +217,7 @@ public class PathUtils {
} else {
return null;
}
path = trimRight(separator, path.trim());
path = trimRight(separator, path);
idx = path.lastIndexOf(separator);
if (idx != -1) {
if (path.startsWith(String.valueOf(separator)) && path.indexOf(separator) == idx) {
......@@ -248,7 +243,7 @@ public class PathUtils {
} else {
return path;
}
path = trimRight(separator, path.trim());
path = trimRight(separator, path);
idx = path.lastIndexOf(separator);
if (idx != -1) {
if (path.startsWith(String.valueOf(separator)) && path.indexOf(separator) == idx) {
......@@ -288,7 +283,7 @@ public class PathUtils {
}
if (rp != null) {
commonParent = files[0].resolve(rp).normalize();
commonParent = (commonParent.toString() == null || commonParent.toString().trim().isEmpty()) ? null
commonParent = (commonParent.toString() == null || commonParent.toString().isEmpty()) ? null
: commonParent;
}
}
......@@ -325,7 +320,7 @@ public class PathUtils {
}
if (rp != null) {
commonParent = file1.resolve(rp).normalize();
commonParent = (commonParent.toString() == null || commonParent.toString().trim().isEmpty()) ? null
commonParent = (commonParent.toString() == null || commonParent.toString().isEmpty()) ? null
: commonParent;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment