INT-4305: (S)FTP: Remove Local File Before Rename
JIRA: https://jira.spring.io/browse/INT-4305 The `File.renameTo()` operation may fail, therefore the content of the local file isn't changed, but since we change `setLastModified()` anyway, this file might be eligible for local polling. So, we end up with the same content from local file in a new message, meanwhile we expect a new content from the remote file * Check the `File.renameTo()` result and attempt to `delete()` for existing local file * When file isn't renames remove the remote file from the `filter` to let it be transferred one more time on the next poll. The local file might be opened for processing, so this way we postpone a fresh remote file for the future poll rounds * Modify `copyFileToLocalDirectory()` to return `boolean` to reflect the fact of copy. This way we check the real number of transferred files **Cherry-pick to 4.3.x** Do not transfer remote file if we can't remove local one Polishing Log Messages
This commit is contained in:
committed by
Gary Russell
parent
36ac9f2203
commit
72bd4e5bcf
@@ -60,27 +60,27 @@ public abstract class RemoteFileTestSupport {
|
||||
protected volatile File targetLocalDirectory;
|
||||
|
||||
public File getSourceRemoteDirectory() {
|
||||
return sourceRemoteDirectory;
|
||||
return this.sourceRemoteDirectory;
|
||||
}
|
||||
|
||||
public File getTargetRemoteDirectory() {
|
||||
return targetRemoteDirectory;
|
||||
return this.targetRemoteDirectory;
|
||||
}
|
||||
|
||||
public String getTargetRemoteDirectoryName() {
|
||||
return targetRemoteDirectory.getAbsolutePath() + File.separator;
|
||||
return this.targetRemoteDirectory.getAbsolutePath() + File.separator;
|
||||
}
|
||||
|
||||
public File getSourceLocalDirectory() {
|
||||
return sourceLocalDirectory;
|
||||
return this.sourceLocalDirectory;
|
||||
}
|
||||
|
||||
public File getTargetLocalDirectory() {
|
||||
return targetLocalDirectory;
|
||||
return this.targetLocalDirectory;
|
||||
}
|
||||
|
||||
public String getTargetLocalDirectoryName() {
|
||||
return targetLocalDirectory.getAbsolutePath() + File.separator;
|
||||
return this.targetLocalDirectory.getAbsolutePath() + File.separator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,12 +70,13 @@ public class AbstractRemoteFileSynchronizerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyFileToLocalDirectory(String remoteDirectoryPath, String remoteFile, File localDirectory,
|
||||
Session<String> session) throws IOException {
|
||||
protected boolean copyFileToLocalDirectory(String remoteDirectoryPath, String remoteFile,
|
||||
File localDirectory, Session<String> session) throws IOException {
|
||||
if ("bar".equals(remoteFile) && failWhenCopyingBar.getAndSet(false)) {
|
||||
throw new IOException("fail");
|
||||
}
|
||||
count.incrementAndGet();
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -162,9 +163,10 @@ public class AbstractRemoteFileSynchronizerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyFileToLocalDirectory(String remoteDirectoryPath, String remoteFile, File localDirectory,
|
||||
Session<String> session) throws IOException {
|
||||
protected boolean copyFileToLocalDirectory(String remoteDirectoryPath, String remoteFile,
|
||||
File localDirectory, Session<String> session) throws IOException {
|
||||
count.incrementAndGet();
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user