Skip to content

Commit

Permalink
fix an issue with jar path that contains a spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
elzoughby committed Aug 31, 2018
1 parent f7aa68e commit 6d944de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions .idea/artifacts/vdm.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.toilelibre.libe.curl.Curl;

import java.io.*;
import java.net.URISyntaxException;


public class Main extends Application {
Expand All @@ -35,8 +36,15 @@ public class Main extends Application {
public static final String USER_HOME = System.getProperty("user.home").replaceAll("[/\\\\]$", "");
public static final String APP_DATA_DIRECTORY = DataHandler.getAppDataDirectory();

private static final String RAW_JAR_PATH = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath().replaceAll("[/\\\\]$", "").replace("/", SEPARATOR);
public static final String JAR_PATH = OS_NAME.contains("win")? RAW_JAR_PATH.replaceAll("^[/\\\\]", "") : RAW_JAR_PATH;
private static String rawJarPath;
static {
try {
rawJarPath = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getAbsolutePath();
} catch (URISyntaxException ex) {
throw new RuntimeException(ex);
}
}
public static final String JAR_PATH = rawJarPath.replaceAll("[/\\\\]$", "");
public static final String INSTALL_PATH = JAR_PATH.replace(SEPARATOR + "app" + SEPARATOR + "vdm.jar", "");
public static final String EXECUTABLE_NAME = OS_NAME.contains("win")? "vdm.exe" : "vdm";
public static final String EXECUTABLE_PATH = INSTALL_PATH + SEPARATOR + EXECUTABLE_NAME;
Expand Down Expand Up @@ -119,6 +127,7 @@ public void start(Stage primaryStage) {
DataHandler.getAppPreferences().replace("Main.height", newValue.doubleValue());
DataHandler.writeAppPreferences();
});
appStage.setOnCloseRequest(event -> appStage.close());

TrayHandler.initSystemTray();
TrayHandler.initNotifications();
Expand All @@ -137,9 +146,6 @@ protected Void call() {

Label statusLabel = (Label) loader.getNamespace().get("statusLabel");

// Disable closing the app window until it finishes updating
Platform.runLater(() -> appStage.setOnCloseRequest(Event::consume));

// Load previous download items data
Platform.runLater(() -> statusLabel.setText("Loading data"));
DataHandler.loadSavedItems();
Expand Down Expand Up @@ -197,11 +203,7 @@ protected Void call() {
}

// Go to home page
Platform.runLater(() -> {
appStage.setOnCloseRequest(event -> appStage.close());
appStage.setOnShown(null);
goForward();
});
Platform.runLater(Main::goForward);

return null;
}
Expand Down

0 comments on commit 6d944de

Please sign in to comment.