From 5138935c20ce7d98db72280da199403dcdf76d18 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 2 Jun 2019 09:33:28 +0100 Subject: [PATCH] add options for portable installation, issue #2 --- gui/griffon-app/lifecycle/Ready.groovy | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gui/griffon-app/lifecycle/Ready.groovy b/gui/griffon-app/lifecycle/Ready.groovy index e69c6929..cf37d440 100644 --- a/gui/griffon-app/lifecycle/Ready.groovy +++ b/gui/griffon-app/lifecycle/Ready.groovy @@ -28,7 +28,11 @@ class Ready extends AbstractLifecycleHandler { @Override void execute() { log.info "starting core services" - def home = System.getProperty("user.home") + File.separator + ".MuWire" + def portableHome = System.getProperty("portable.home") + def home = portableHome == null ? + System.getProperty("user.home") + File.separator + ".MuWire" : + portableHome + home = new File(home) if (!home.exists()) { log.info("creating home dir") @@ -64,8 +68,13 @@ class Ready extends AbstractLifecycleHandler { nickname = nickname.trim() break } + props.setNickname(nickname) - while(true) { + + def portableDownloads = System.getProperty("portable.downloads") + if (portableDownloads != null) { + props.downloadLocation = new File(portableDownloads) + } else { def chooser = new JFileChooser() chooser.setDialogTitle("Select a directory where downloads will be saved") chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) @@ -75,9 +84,8 @@ class Ready extends AbstractLifecycleHandler { System.exit(0) } props.downloadLocation = chooser.getSelectedFile() - break } - props.setNickname(nickname) + propsFile.withOutputStream { props.write(it) }