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

@ -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) {