Spring Integration SFTP fileExistsMode进行mv操作

问题描述 投票:0回答:1

为什么mv操作时不能使用FileExistsMode? FAIL是mv操作的默认值吗?

AbstractRemoteFileOutboundGateway.Command.MV
.fileExistsMode(FileExistsMode.REPLACE)

为什么不做MV呢?也许在下一个版本中拉取请求?

spring-integration spring-integration-sftp spring-integration-file
1个回答
0
投票

SftpSession
中的逻辑是这样的:

public void rename(String pathFrom, String pathTo) throws IOException {
    if (this.sftpClient.getVersion() >= SftpConstants.SFTP_V5) {
        this.sftpClient.rename(pathFrom, pathTo, SftpClient.CopyMode.Overwrite);
    }
    else {
        remove(pathTo);
        this.sftpClient.rename(pathFrom, pathTo);
    }
}

所以,它总是覆盖现有文件。

您可以考虑在发送 MV 命令之前使用

SftpFileTemplate.exists()

我们确实可以考虑改进

AbstractRemoteFileOutboundGateway.mv()
逻辑以使用提供的
FileExistsMode
。请随意提出 GH 问题并贡献这样的功能。

© www.soinside.com 2019 - 2024. All rights reserved.