GH-3652: File gateway: don't try delete no file
Fixes spring-projects/spring-integration#3652 Do not try to delete non-existing file in `FileExistMode.REPLACE` in the `AbstractRemoteFileOutboundGateway` **Cherry-pick to `5.4.x` & `5.3.x`**
This commit is contained in:
committed by
Artem Bilan
parent
e50209d045
commit
f16f5c6867
@@ -68,6 +68,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Mauro Molinari
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -1082,9 +1083,9 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
|
||||
FileExistsMode existsMode = this.fileExistsMode;
|
||||
boolean appending = FileExistsMode.APPEND.equals(existsMode);
|
||||
boolean exists = localFile.exists();
|
||||
boolean replacing = FileExistsMode.REPLACE.equals(existsMode)
|
||||
|| (exists && FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode)
|
||||
&& localFile.lastModified() != getModified(fileInfo));
|
||||
boolean replacing = exists && (FileExistsMode.REPLACE.equals(existsMode)
|
||||
|| (FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode)
|
||||
&& localFile.lastModified() != getModified(fileInfo)));
|
||||
if (!exists || appending || replacing) {
|
||||
OutputStream outputStream;
|
||||
String tempFileName = localFile.getAbsolutePath() + this.remoteFileTemplate.getTemporaryFileSuffix();
|
||||
|
||||
Reference in New Issue
Block a user