Skip to content

Commit

Permalink
Fix #3: support non existing directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Moussaud committed Apr 26, 2016
1 parent 1fe3fd5 commit cf10c30
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package ext.deployit.community.extra.steps;

import com.xebialabs.deployit.plugin.api.flow.ExecutionContext;
import com.xebialabs.deployit.plugin.api.flow.Preview;
import com.xebialabs.deployit.plugin.api.flow.PreviewStep;
import com.xebialabs.deployit.plugin.api.flow.StepExitCode;
import com.xebialabs.deployit.plugin.api.rules.RulePostConstruct;
import com.xebialabs.deployit.plugin.api.rules.StepMetadata;
Expand All @@ -27,7 +25,7 @@
import static java.lang.String.format;

@StepMetadata(name = "upload-artifact")
public class UploadArtifactStep extends BaseArtifactStep {
public class UploadArtifactStep extends BaseArtifactStep {

@StepParameter(name = "artifact", description = "Artifact that has been uploaded to the target host.")
private Artifact artifact;
Expand Down Expand Up @@ -78,7 +76,6 @@ public Preview getPreview() {

public ActionBuilder analyze(OverthereConnection connection) throws Exception {
ActionBuilder actions = new ActionBuilder();

final OverthereFile remoteTargetPath = connection.getFile(getTargetPath());
if (!remoteTargetPath.exists()) {
actions.systemOut("Remote path " + getTargetPath() + " does not exists, create it");
Expand All @@ -99,15 +96,20 @@ public ActionBuilder analyze(OverthereConnection connection) throws Exception {
}


if (artifactFile.isDirectory()) {
actions.systemOut("Artifact: Folder");
if (artifactFile.isDirectory() && !remoteTargetPath.exists()) {
actions.systemOut("Artifact: new Folder ");
actions.systemOut(format("Copy %s -> %s", artifactFilePath, remoteTargetPath.getPath()));
actions.copyTo(artifactFile, remoteTargetPath);
}

if (artifactFile.isDirectory() && remoteTargetPath.exists()) {
actions.systemOut("Artifact: existing Folder");
DirectoryDiff diff = new DirectoryDiff(remoteTargetPath, artifactFile);
final DirectoryChangeSet changeSet = diff.diff();
actions.systemOut(format("%d files to be removed.", changeSet.getRemoved().size()));
actions.systemOut(format("%d new files to be copied.", changeSet.getAdded().size()));
actions.systemOut(format("%d modified files to be copied.", changeSet.getChanged().size()));


if (changeSet.getRemoved().size() > 0) {
actions.systemOut("Start removal of files...");
DirectoryChangeSet previousChangeSet = null;
Expand Down

0 comments on commit cf10c30

Please sign in to comment.