From 758f32cc97d1755634faf20ad1bc3fe7db370c56 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Fri, 22 Jul 2022 13:59:59 +0300 Subject: [PATCH] #1379 check for empty dir --- .../java/com/rultor/agents/daemons/StartsDaemon.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rultor/agents/daemons/StartsDaemon.java b/src/main/java/com/rultor/agents/daemons/StartsDaemon.java index 4a89d7ea34..163563a847 100644 --- a/src/main/java/com/rultor/agents/daemons/StartsDaemon.java +++ b/src/main/java/com/rultor/agents/daemons/StartsDaemon.java @@ -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; } @@ -110,10 +111,15 @@ public Iterable 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(