FileWatcher debugging.

This commit is contained in:
didfet
2015-03-14 07:41:18 +01:00
parent 797f6f41bb
commit 8d7b0cd59d

View File

@@ -68,7 +68,8 @@ public class FileWatcher implements FileAlterationListener {
public void checkFiles() throws IOException { public void checkFiles() throws IOException {
logger.debug("Checking files"); logger.debug("Checking files");
//printWatchMap(); logger.trace("==============");
for(FileAlterationObserver observer : observerList) { for(FileAlterationObserver observer : observerList) {
observer.checkAndNotify(); observer.checkAndNotify();
} }
@@ -77,15 +78,22 @@ public class FileWatcher implements FileAlterationListener {
printWatchMap(); printWatchMap();
} }
public void readFiles() {
logger.debug("Reading files");
logger.trace("==============");
}
private void processModifications() throws IOException { private void processModifications() throws IOException {
for(File file : changedWatchMap.keySet()) { for(File file : changedWatchMap.keySet()) {
FileState state = changedWatchMap.get(file); FileState state = changedWatchMap.get(file);
logger.trace("Checking file : " + file.getCanonicalPath()); if(logger.isTraceEnabled()) {
logger.trace("-- Last modified : " + state.getLastModified()); logger.trace("Checking file : " + file.getCanonicalPath());
logger.trace("-- Size : " + state.getSize()); logger.trace("-- Last modified : " + state.getLastModified());
logger.trace("-- Directory : " + state.getDirectory()); logger.trace("-- Size : " + state.getSize());
logger.trace("-- Filename : " + state.getFileName()); logger.trace("-- Directory : " + state.getDirectory());
logger.trace("-- Filename : " + state.getFileName());
}
// Determine if file is still the same // Determine if file is still the same
logger.trace("Determine if file has just been written to"); logger.trace("Determine if file has just been written to");
@@ -125,7 +133,9 @@ public class FileWatcher implements FileAlterationListener {
for(File otherFile : watchMap.keySet()) { for(File otherFile : watchMap.keySet()) {
FileState otherState = watchMap.get(otherFile); FileState otherState = watchMap.get(otherFile);
if(otherState != null && state.getSize() >= otherState.getSize() && state.getDirectory().equals(otherState.getDirectory())) { if(otherState != null && state.getSize() >= otherState.getSize() && state.getDirectory().equals(otherState.getDirectory())) {
logger.trace("Comparing to : " + otherFile.getCanonicalPath()); if(logger.isTraceEnabled()) {
logger.trace("Comparing to : " + otherFile.getCanonicalPath());
}
// File in the same directory which was smaller // File in the same directory which was smaller
if(otherState.getSignatureLength() == state.getSignatureLength() && otherState.getSignature() == state.getSignature()) { if(otherState.getSignatureLength() == state.getSignatureLength() && otherState.getSignature() == state.getSignature()) {
// File is the same // File is the same
@@ -156,7 +166,9 @@ public class FileWatcher implements FileAlterationListener {
// Refresh file state // Refresh file state
logger.trace("Refreshing file state"); logger.trace("Refreshing file state");
for(File file : changedWatchMap.keySet()) { for(File file : changedWatchMap.keySet()) {
logger.trace("Refreshing file : " + file.getCanonicalPath()); if(logger.isTraceEnabled()) {
logger.trace("Refreshing file : " + file.getCanonicalPath());
}
FileState state = changedWatchMap.get(file); FileState state = changedWatchMap.get(file);
FileState oldState = state.getOldFileState(); FileState oldState = state.getOldFileState();
if(oldState == null) { if(oldState == null) {