This commit is contained in:
didfet
2016-08-20 16:25:24 +02:00
parent b94203dfab
commit 3970ebdba9
2 changed files with 21 additions and 0 deletions

View File

@@ -52,6 +52,8 @@ public class FileState {
private FileState oldFileState;
@JsonIgnore
private Event fields;
@JsonIgnore
private boolean matchedToNewFile = false;
public FileState() {
}
@@ -160,6 +162,7 @@ public class FileState {
public void setOldFileState(FileState oldFileState) {
this.oldFileState = oldFileState;
oldFileState.setMatchedToNewFile(true);
}
public void deleteOldFileState() {
@@ -176,6 +179,14 @@ public class FileState {
public void setFields(Event fields) {
this.fields = fields;
}
public boolean isMatchedToNewFile() {
return matchedToNewFile;
}
public void setMatchedToNewFile(boolean matchedToNewFile) {
this.matchedToNewFile = matchedToNewFile;
}
@Override
public String toString() {

View File

@@ -188,6 +188,16 @@ public class FileWatcher {
if(logger.isDebugEnabled()) {
logger.debug("File " + state.getFile() + " has been truncated or created, not retrieving pointer");
}
oldState = oldWatchMap.get(state.getFile());
if(oldState != null && ! oldState.isMatchedToNewFile()) {
if(logger.isDebugEnabled()) {
logger.debug("File " + state.getFile() + " has been replaced and not renamed, removing from watchMap");
}
try {
oldState.getRandomAccessFile().close();
} catch(Exception e) {}
oldWatchMap.remove(state.getFile());
}
} else {
if(logger.isInfoEnabled() && ! state.getFileName().equals(oldState.getFileName()))
{