Skip to content

Commit 02c4a21

Browse files
committed
Fix lack of URL decoding when deploying
This was causing problems when the full path of the local GRIP jar has spaces in it. Closes #435
1 parent 756ab20 commit 02c4a21

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

ui/src/main/java/edu/wpi/grip/ui/DeployController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.InputStreamReader;
2828
import java.io.InterruptedIOException;
2929
import java.io.StringWriter;
30+
import java.net.URLDecoder;
3031
import java.net.UnknownHostException;
3132
import java.util.Optional;
3233
import java.util.logging.Level;
@@ -42,6 +43,8 @@
4243
public class DeployController {
4344
private final static String GRIP_JAR = "grip.jar";
4445
private final static String PROJECT_FILE = "project.grip";
46+
private final static String LOCAL_GRIP_JAR = URLDecoder.decode(
47+
Project.class.getProtectionDomain().getCodeSource().getLocation().getPath());
4548

4649
@FXML private TextField address;
4750
@FXML private TextField user;
@@ -149,8 +152,7 @@ public StreamCopier.Listener file(String name, long size) {
149152

150153
// Upload the GRIP core JAR and the serialized project to the robot
151154
scp.upload(new StringInMemoryFile(PROJECT_FILE, projectWriter.toString()), deployDir + "/");
152-
scp.upload(new FileSystemFile(Project.class.getProtectionDomain().getCodeSource().getLocation().getPath()),
153-
deployDir + "/" + GRIP_JAR);
155+
scp.upload(new FileSystemFile(LOCAL_GRIP_JAR), deployDir + "/" + GRIP_JAR);
154156

155157
// Stop the pipeline before running it remotely, so the two instances of GRIP don't try to publish to the
156158
// same NetworkTables keys.
@@ -160,7 +162,8 @@ public StreamCopier.Listener file(String name, long size) {
160162
setStatusAsync("Running GRIP", false);
161163
Session session = ssh.startSession();
162164
session.allocateDefaultPTY();
163-
Session.Command cmd = session.exec(javaHome + "/bin/java -jar " + deployDir + "/" + GRIP_JAR + " " + deployDir + "/" + PROJECT_FILE);
165+
Session.Command cmd = session.exec(javaHome + "/bin/java -jar " + deployDir + "/" + GRIP_JAR + "' '"
166+
+ deployDir + "/" + PROJECT_FILE + "'");
164167

165168
LineReader inputReader = new LineReader(new InputStreamReader(cmd.getInputStream()));
166169
while (isNotCanceled()) {

0 commit comments

Comments
 (0)