bug fixes

* fixed a crash at the first start on linux
* fixed a crash caused by "" as source path
* fixed HomeFlix is unable to start because sources.json is missing
* removed one unnecessary restart
This commit is contained in:
Jannik 2018-03-13 18:08:30 +01:00
parent 6282c8ce98
commit 4be971efee
4 changed files with 15 additions and 10 deletions

View File

@ -112,12 +112,6 @@ public class Main extends Application {
mainWindowController.setAutoUpdate(false);
mainWindowController.setLocal(local);
mainWindowController.saveSettings();
try {
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); // start again (preventing Bugs) TODO is this really needed
System.exit(0); // finishes it self
} catch (Exception e) {
LOGGER.error("error while restarting HomeFlix", e);
}
}
if (!posterCache.exists()) {
@ -152,10 +146,11 @@ public class Main extends Application {
break;
}
Alert alert = new Alert(AlertType.CONFIRMATION); //new alert with file-chooser
Alert alert = new Alert(AlertType.CONFIRMATION); //new alert with DirectoryChooser
alert.setTitle("Project HomeFlix");
alert.setHeaderText(bundle.getString("firstStartHeader"));
alert.setContentText(bundle.getString("firstStartContent"));
alert.setResizable(true);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
@ -165,9 +160,12 @@ public class Main extends Application {
path = selectedDirectory.getAbsolutePath();
} else {
path = "";
LOGGER.warn("No directory selected!");
System.exit(1);
}
return path;
}
public static void main(String[] args) {

View File

@ -729,12 +729,17 @@ public class MainWindowController {
try {
// read old array
newsources = Json.parse(new FileReader(main.getDirectory() + "/sources.json")).asArray();
File oldSources = new File(main.getDirectory() + "/sources.json");
if (oldSources.exists()) {
newsources = Json.parse(new FileReader(main.getDirectory() + "/sources.json")).asArray();
} else {
newsources = Json.array();
}
// add new source
Writer writer = new FileWriter(main.getDirectory() + "/sources.json");
source = Json.object().add("path", path).add("mode", mode);
newsources.add(source);
Writer writer = new FileWriter(main.getDirectory() + "/sources.json");
newsources.writeTo(writer);
writer.close();
} catch (IOException e) {

View File

@ -59,5 +59,6 @@ metascore = Metascore
imdbRating = IMDB-Bewertung
type = Type
#first start
firstStartHeader = Es ist kein Stammverzeichnis f\u00FCr Filme angegeben!
firstStartContent = Stammverzeichniss angeben?

View File

@ -59,5 +59,6 @@ metascore = Metascore
imdbRating = IMDB-Rating
type = Type
#first start
firstStartHeader = There is no root directory for movies!
firstStartContent = Specify a root directory?