Skip to content

Commit

Permalink
0003197: One file trigger that is configured with two routers to two
Browse files Browse the repository at this point in the history
different target locations syncs only to one location
  • Loading branch information
chenson42 committed Jul 12, 2017
1 parent 981eb48 commit a8e6a7b
Showing 1 changed file with 16 additions and 7 deletions.
Expand Up @@ -156,7 +156,8 @@ public void end(Batch batch, boolean inError) {
FileSyncZipScript script = createFileSyncZipScript(batch.getTargetNodeId());
script.buildScriptStart(batch);

Map<String, LastEventType> entries = new HashMap<String, LastEventType>();
Map<String, LastEventType> entriesByLastEventType = new HashMap<String, LastEventType>();
Map<String, String> entriesByLastRouterId = new HashMap<String, String>();
for (FileSnapshot snapshot : snapshotEvents) {
FileTriggerRouter triggerRouter = fileSyncService.getFileTriggerRouter(
snapshot.getTriggerId(), snapshot.getRouterId());
Expand Down Expand Up @@ -185,17 +186,22 @@ public void end(Batch batch, boolean inError) {
}

String targetFile = "targetBaseDir + \"/\" + targetRelativeDir + \"/\" + targetFileName";


LastEventType previousEventForEntry = entries.get(entryName.toString());
boolean process = true;
LastEventType previousEventForEntry = entriesByLastEventType.get(entryName.toString());
boolean addFileToZip = true;
if (previousEventForEntry != null) {
if ((previousEventForEntry == eventType)
|| (previousEventForEntry == LastEventType.CREATE && eventType == LastEventType.MODIFY)) {
process = false;
addFileToZip = false;
}
}

if (process) {

String lastRouterId = entriesByLastRouterId.get(entryName.toString());
boolean addFileToScript = !snapshot.getRouterId().equals(lastRouterId);

if (addFileToZip) {
if (eventType != LastEventType.DELETE) {
if (file.exists()) {
byteCount += file.length();
Expand All @@ -212,14 +218,17 @@ public void end(Batch batch, boolean inError) {
}
}
zos.closeEntry();
entries.put(entryName.toString(), eventType);
entriesByLastEventType.put(entryName.toString(), eventType);
entriesByLastRouterId.put(entryName.toString(), snapshot.getRouterId());
} else {
log.warn(
"Could not find the {} file to package for synchronization. Skipping it.",
file.getAbsolutePath());
}
}

}

if (addFileToScript) {
script.buildScriptFileSnapshot(batch, snapshot, triggerRouter, fileTrigger,
file, targetBaseDir, targetFile);
}
Expand Down

0 comments on commit a8e6a7b

Please sign in to comment.