Skip to content

Commit

Permalink
Implement change to only lowerCase the Windows drive letter instead o…
Browse files Browse the repository at this point in the history
…f the entire file path. Resolves marklogic#130
  • Loading branch information
hansenmc committed Mar 21, 2022
1 parent 61f0e02 commit f05bc58
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.nio.file.Path;
import java.util.Date;
import java.util.Properties;

Expand Down Expand Up @@ -129,14 +130,27 @@ public void saveLastLoadedTimestamp(File file, Date date) {
* @param file
* @return a string that can be used as a key for a Properties object
*/
protected String buildKey(File file) {
String path = file.getAbsolutePath().toLowerCase();
final String key = host != null ? host + ":" + path : path;
if (logger.isDebugEnabled()) {
logger.debug("Key for file " + file.getAbsolutePath() + ": " + key);
}
return key;
}
protected String buildKey(File file) {
String path = normalizeDriveLetter(file);
final String key = host != null ? host + ":" + path : path;
if (logger.isDebugEnabled()) {
logger.debug("Key for file " + file.getAbsolutePath() + ": " + key);
}
return key;
}

protected String normalizeDriveLetter(File file) {
Path absolutePath = file.toPath().toAbsolutePath();
String path = absolutePath.toString();
Path root = absolutePath.getRoot();
if (root != null) {
String drive = root.toString();
if (path.startsWith(drive)) {
path = drive.toLowerCase() + path.substring(drive.length());
}
}
return path;
}

public void setMinimumFileTimestampToLoad(long minimumFileTimestampToLoad) {
this.minimumFileTimestampToLoad = minimumFileTimestampToLoad;
Expand Down

0 comments on commit f05bc58

Please sign in to comment.