NIFI-9196 Corrected FetchSFTP Move File destination formatting

- Changed FetchSFTP to use String.format() instead of  File.getAbsolutePath() for defining the destination path as part of the Move File completion strategy

This closes #7072

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Emilio Setiadarma 2023-03-20 13:44:54 -07:00 committed by exceptionfactory
parent 132bce4245
commit cac76e339d
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
1 changed files with 3 additions and 3 deletions

View File

@ -350,13 +350,13 @@ public abstract class FetchFileTransfer extends AbstractProcessor {
try {
final String absoluteTargetDirPath = transfer.getAbsolutePath(flowFile, targetDir);
final File targetFile = new File(absoluteTargetDirPath, simpleFilename);
if (context.getProperty(MOVE_CREATE_DIRECTORY).asBoolean()) {
// Create the target directory if necessary.
transfer.ensureDirectoryExists(flowFile, targetFile.getParentFile());
transfer.ensureDirectoryExists(flowFile, new File(absoluteTargetDirPath));
}
transfer.rename(flowFile, filename, targetFile.getAbsolutePath());
final String destinationPath = String.format("%s/%s", absoluteTargetDirPath, simpleFilename);
transfer.rename(flowFile, filename, destinationPath);
} catch (final IOException ioe) {
getLogger().warn("Successfully fetched the content for {} from {}:{}{} but failed to rename the remote file due to {}",