Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively put files sometimes #10

Merged
merged 8 commits into from
Feb 21, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/io/dockstore/provision/S3CmdPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ public boolean uploadTo(String destPath, Path sourceFile, Optional<String> metad
} catch (IOException e) {
throw new RuntimeException(e);
}
String recursive = "";

// If the destination end with a slash, source could be either a file or a directory
// It can technically be either, but we're recursively putting the source file as if it's a directory because there's no side effect
// If the destination does not end with a slash, source must be a file
if (destPath.endsWith("/")) {
recursive = "-r ";
}

String modifiedChunkSize = getChunkSize(sizeInBytes);
destPath = destPath.replace("s3cmd://", "s3://");
String trimmedPath = destPath.replace("s3://", "");
Expand All @@ -189,7 +198,7 @@ public boolean uploadTo(String destPath, Path sourceFile, Optional<String> metad
LOG.error("Could not create bucket");
}
}
String command = client + " -c " + configLocation + " put " + sourceFile.toString().replace(" ", "%32") + " " + destPath
String command = client + " -c " + configLocation + " put " + recursive + sourceFile.toString().replace(" ", "%32") + " " + destPath
+ modifiedChunkSize;
int exitCode = executeConsoleCommand(command, true);
return checkExitCode(exitCode);
Expand Down