Skip to content

Commit

Permalink
Disable remote temporary file rename logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sakama committed Dec 21, 2017
1 parent 41ceeff commit af09b1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/main/java/org/embulk/output/sftp/SftpFileOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ public void finish()
closeCurrentFile();
String fileName = getOutputFilePath();
String temporaryFileName = fileName + temporaryFileSuffix;
sftpUtils.uploadFile(tempFile, temporaryFileName);
/*
#37 causes permission failure while renaming remote file.
https://github.com/embulk/embulk-output-sftp/issues/40
*/
//sftpUtils.uploadFile(tempFile, temporaryFileName);
sftpUtils.uploadFile(tempFile, fileName);

Map<String, String> executedFiles = new HashMap<>();
executedFiles.put("temporary_filename", temporaryFileName);
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/org/embulk/output/sftp/SftpFileOutputPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,21 @@ public void cleanup(TaskSource taskSource,
int taskCount,
List<TaskReport> successTaskReports)
{
SftpUtils sftpUtils = new SftpUtils(taskSource.loadTask(PluginTask.class));
for (TaskReport report : successTaskReports) {
List<Map<String, String>> moveFileList = report.get(List.class, "file_list");
for (Map<String, String> pairFiles : moveFileList) {
String temporaryFileName = pairFiles.get("temporary_filename");
String realFileName = pairFiles.get("real_filename");

sftpUtils.renameFile(temporaryFileName, realFileName);
}
}
sftpUtils.close();
/*
#37 causes permission failure while renaming remote file.
https://github.com/embulk/embulk-output-sftp/issues/40
*/
// SftpUtils sftpUtils = new SftpUtils(taskSource.loadTask(PluginTask.class));
// for (TaskReport report : successTaskReports) {
// List<Map<String, String>> moveFileList = report.get(List.class, "file_list");
// for (Map<String, String> pairFiles : moveFileList) {
// String temporaryFileName = pairFiles.get("temporary_filename");
// String realFileName = pairFiles.get("real_filename");
//
// sftpUtils.renameFile(temporaryFileName, realFileName);
// }
// }
// sftpUtils.close();
}

@Override
Expand Down

0 comments on commit af09b1c

Please sign in to comment.