Check if workspace is valid during startup (fixes #34)

parent 111c5a12
Pipeline #7459 passed with stages
in 5 minutes and 27 seconds
......@@ -65,7 +65,22 @@ internal class Main : Application() {
val workspace = if ("workspace" in Config) {
// Load workspace from config
File(Config.workspace)
var ws = File(Config.workspace)
if (!ws.exists() || !ws.isDirectory) {
// The stored path is not valid, choose a new one.
PseucoAlert(Alert.AlertType.WARNING).apply {
title = "Invalid workspace"
contentText = "The stored workspace '${ws.absolutePath}' does not exist. Please choose a new one."
}.showAndWait()
ws = DirectoryChooser().apply {
title = "Update workspace"
initialDirectory = Workspace.DEFAULT
}.showDialog(primaryStage)?.also {
Config.workspace = it.absolutePath
Config.save()
} ?: exitProcess(0)
}
ws
} else {
// Choose workspace
DirectoryChooser().apply {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment