mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Move appdir creation to main
This commit is contained in:
parent
87fa1d4ae2
commit
c9f685b0df
5 changed files with 29 additions and 36 deletions
|
@ -17,7 +17,6 @@
|
|||
|
||||
package io.bitsquare.app.gui;
|
||||
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.gui.SystemTray;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
|
@ -34,10 +33,6 @@ import com.google.inject.Injector;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import viewfx.view.View;
|
||||
import viewfx.view.ViewLoader;
|
||||
import viewfx.view.support.CachingViewLoader;
|
||||
|
@ -53,9 +48,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static io.bitsquare.app.BitsquareEnvironment.*;
|
||||
import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY;
|
||||
|
||||
public class BitsquareApp extends Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(BitsquareApp.class);
|
||||
|
@ -82,14 +76,6 @@ public class BitsquareApp extends Application {
|
|||
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) ->
|
||||
Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
|
||||
|
||||
|
||||
// initialize the application data directory (if necessary)
|
||||
|
||||
initAppDir(
|
||||
env.getRequiredProperty(APP_DATA_DIR_KEY),
|
||||
env.getRequiredProperty(APP_DATA_DIR_CLEAN_KEY, boolean.class));
|
||||
|
||||
|
||||
// load and apply any stored settings
|
||||
|
||||
User user = injector.getInstance(User.class);
|
||||
|
@ -160,22 +146,4 @@ public class BitsquareApp extends Application {
|
|||
bitsquareAppModule.close(injector);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
private void initAppDir(String appDir, boolean doClean) {
|
||||
Path dir = Paths.get(appDir);
|
||||
if (Files.exists(dir)) {
|
||||
if (!Files.isWritable(dir))
|
||||
throw new BitsquareException("Application data directory '%s' is not writeable", dir);
|
||||
if (doClean)
|
||||
FileSystemUtils.deleteRecursively(dir.toFile());
|
||||
else
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Files.createDirectory(dir);
|
||||
} catch (IOException ex) {
|
||||
throw new BitsquareException(ex, "Application data directory '%s' could not be created", dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.app.gui;
|
||||
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.app.BitsquareEnvironment;
|
||||
import io.bitsquare.app.BitsquareExecutable;
|
||||
import io.bitsquare.btc.BitcoinNetwork;
|
||||
|
@ -25,6 +26,11 @@ import io.bitsquare.network.Node;
|
|||
import io.bitsquare.util.joptsimple.EnumValueConverter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -69,6 +75,10 @@ public class BitsquareAppMain extends BitsquareExecutable {
|
|||
}
|
||||
BitsquareEnvironment bitsquareEnvironment = new BitsquareEnvironment(options);
|
||||
String updatesDirectory = bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY);
|
||||
|
||||
// app dir need to be setup before UpdateFX bootstrap
|
||||
initAppDir(updatesDirectory);
|
||||
|
||||
UpdateFX.bootstrap(BitsquareAppMain.class, new File(updatesDirectory).toPath(), args);
|
||||
}
|
||||
|
||||
|
@ -82,6 +92,21 @@ public class BitsquareAppMain extends BitsquareExecutable {
|
|||
new BitsquareAppMain().execute(args);
|
||||
}
|
||||
|
||||
private static void initAppDir(String appDir) {
|
||||
Path dir = Paths.get(appDir);
|
||||
if (Files.exists(dir)) {
|
||||
if (!Files.isWritable(dir))
|
||||
throw new BitsquareException("Application data directory '%s' is not writeable", dir);
|
||||
else
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Files.createDirectory(dir);
|
||||
} catch (IOException ex) {
|
||||
throw new BitsquareException(ex, "Application data directory '%s' could not be created", dir);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeOptionParsing(OptionParser parser) {
|
||||
parser.accepts(USER_DATA_DIR_KEY, description("User data directory", DEFAULT_USER_DATA_DIR))
|
||||
|
|
|
@ -54,7 +54,7 @@ public class UpdateProcess {
|
|||
// Edit version for updateFX
|
||||
private static final int BUILD_VERSION = 1;
|
||||
|
||||
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("025AA74490F66D195D42D49070D821C96A137496C070A924E5AAB0D6EE8549457E");
|
||||
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("0296CFF54A8B1611499D4C1024E654140AFBB58C505FE4BB7C847B4F4A7C683DF6");
|
||||
private static final String UPDATES_BASE_URL = "http://bitsquare.io/updateFX/";
|
||||
private static final int UPDATE_SIGNING_THRESHOLD = 1;
|
||||
private static final Path ROOT_CLASS_PATH = UpdateFX.findCodePath(BitsquareAppMain.class);
|
||||
|
|
|
@ -9,6 +9,6 @@ mkdir gui/updatefx/site
|
|||
mkdir gui/deploy
|
||||
|
||||
# Copy wallet file from main build
|
||||
java -jar ./updatefx/updatefx-app-1.2.jar --url=http://bitsquare.io/updateFX/ gui/updatefx
|
||||
# java -jar ./updatefx/updatefx-app-1.2.jar --url=http://bitsquare.io/updateFX/ gui/updatefx
|
||||
|
||||
cd package/linux
|
|
@ -9,6 +9,6 @@ mkdir gui\deploy
|
|||
:: mkdir gui\win-32bit
|
||||
|
||||
:: Copy wallet file from main build
|
||||
call java -Xmx2048m -jar ./updatefx/updatefx-app-1.2.jar --url=http://bitsquare.io/updateFX/ gui/updatefx
|
||||
:: call java -Xmx2048m -jar ./updatefx/updatefx-app-1.2.jar --url=http://bitsquare.io/updateFX/ gui/updatefx
|
||||
|
||||
cd package\windows
|
Loading…
Add table
Reference in a new issue