mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
fix bug in extensions
This commit is contained in:
parent
0604b45572
commit
32ecc855f0
@ -16,16 +16,16 @@ public class ExecutionInfo {
|
||||
|
||||
static {
|
||||
extensionTypeToExecutionCommand = new HashMap<>();
|
||||
extensionTypeToExecutionCommand.put("*.jar","java -jar {path}");
|
||||
extensionTypeToExecutionCommand.put("*.py","python {path}");
|
||||
extensionTypeToExecutionCommand.put("*.py3","python3 {path}");
|
||||
extensionTypeToExecutionCommand.put("*.sh","{path}");
|
||||
extensionTypeToExecutionCommand.put("*.exe","{path}");
|
||||
extensionTypeToExecutionCommand.put("*.jar","java -jar \"{path}\"");
|
||||
extensionTypeToExecutionCommand.put("*.py","python \"{path}\"");
|
||||
extensionTypeToExecutionCommand.put("*.py3","python3 \"{path}\"");
|
||||
extensionTypeToExecutionCommand.put("*.sh","\"{path}\"");
|
||||
extensionTypeToExecutionCommand.put("*.exe","\"{path}\"");
|
||||
|
||||
for(String type : extensionTypeToExecutionCommand.keySet()) {
|
||||
extensionTypeToExecutionCommand.put(
|
||||
type,
|
||||
extensionTypeToExecutionCommand.get(type) + " -p {port} -f {filename} -c {cookie}"
|
||||
extensionTypeToExecutionCommand.get(type) + " -p {port} -f \"{filename}\" -c {cookie}"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import gearth.ui.extensions.authentication.Authenticator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
@ -14,7 +15,18 @@ import java.util.Random;
|
||||
*/
|
||||
public class NormalExtensionRunner implements ExtensionRunner {
|
||||
|
||||
public static final String JARPATH = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
|
||||
public static final String JARPATH;
|
||||
|
||||
static {
|
||||
String value;
|
||||
try {
|
||||
value = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParent();
|
||||
} catch (URISyntaxException e) {
|
||||
value = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
|
||||
e.printStackTrace();
|
||||
}
|
||||
JARPATH = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAllExtensions(int port) {
|
||||
@ -45,7 +57,6 @@ public class NormalExtensionRunner implements ExtensionRunner {
|
||||
String realname = String.join(".",Arrays.copyOf(split, split.length-1));
|
||||
String newname = realname + "-" + getRandomString() + ext.substring(1);
|
||||
|
||||
|
||||
Path originalPath = Paths.get(path);
|
||||
Path newPath = Paths.get(
|
||||
JARPATH,
|
||||
@ -72,13 +83,12 @@ public class NormalExtensionRunner implements ExtensionRunner {
|
||||
public void tryRunExtension(String path, int port) {
|
||||
try {
|
||||
String filename = Paths.get(path).getFileName().toString();
|
||||
Runtime.getRuntime().exec(
|
||||
ExecutionInfo.getExecutionCommand(getFileExtension(path))
|
||||
String execCommand = ExecutionInfo.getExecutionCommand(getFileExtension(path))
|
||||
.replace("{path}", path)
|
||||
.replace("{port}", port+"")
|
||||
.replace("{filename}", filename)
|
||||
.replace("{cookie}", Authenticator.generateCookieForExtension(filename))
|
||||
);
|
||||
.replace("{cookie}", Authenticator.generateCookieForExtension(filename));
|
||||
Runtime.getRuntime().exec(execCommand);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user