Skip to content

Commit

Permalink
#1379 check for empty dir
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 22, 2022
1 parent 40d6271 commit 758f32c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/rultor/agents/daemons/StartsDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public final class StartsDaemon extends AbstractAgent {
public StartsDaemon(final Profile prof) {
super(
"/talk/shell[host and port and login and key]",
"/talk/daemon[script and dir and not(started) and not(ended)]"
"/talk/daemon[script and dir and not(started) and not(ended)]",
"/talk/daemon[dir != '']"
);
this.profile = prof;
}
Expand Down Expand Up @@ -110,10 +111,15 @@ public Iterable<Directive> process(final XML xml) {
*/
@RetryOnFailure
public String run(final XML xml) throws IOException {
final XML daemon = xml.nodes("/talk/daemon").get(0);
final Shell shell = new TalkShells(xml).get();
new ProfileDeprecations(this.profile).print(shell);
final String dir = xml.xpath("/talk/daemon/dir/text()").get(0);
if (dir.isEmpty()) {
throw new IllegalArgumentException(
"The dir can't be empty"
);
}
final XML daemon = xml.nodes("/talk/daemon").get(0);
new Shell.Safe(shell).exec(
String.format("cd %s; cat > run.sh", Ssh.escape(dir)),
IOUtils.toInputStream(
Expand Down

0 comments on commit 758f32c

Please sign in to comment.