mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-27 16:17:37 -04:00
Fix broken preferences path
This commit is contained in:
parent
5d56dc62c9
commit
7049ab3a78
7 changed files with 20 additions and 18 deletions
|
@ -30,7 +30,7 @@ class MainModule extends BitsquareModule {
|
||||||
private final Stage primaryStage;
|
private final Stage primaryStage;
|
||||||
|
|
||||||
public MainModule(String appName, Stage primaryStage) {
|
public MainModule(String appName, Stage primaryStage) {
|
||||||
super(ConfigLoader.loadConfig());
|
super(ConfigLoader.loadConfig(appName));
|
||||||
this.appName = appName;
|
this.appName = appName;
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class WalletFacade {
|
||||||
Threading.USER_THREAD = Platform::runLater;
|
Threading.USER_THREAD = Platform::runLater;
|
||||||
|
|
||||||
// If seed is non-null it means we are restoring from backup.
|
// If seed is non-null it means we are restoring from backup.
|
||||||
walletAppKit = new WalletAppKit(params, AppDirectory.dir().toFile(), appName) {
|
walletAppKit = new WalletAppKit(params, AppDirectory.dir(appName).toFile(), appName) {
|
||||||
@Override
|
@Override
|
||||||
protected void onSetupCompleted() {
|
protected void onSetupCompleted() {
|
||||||
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class TomP2PNode {
|
||||||
private static final Logger log = LoggerFactory.getLogger(TomP2PNode.class);
|
private static final Logger log = LoggerFactory.getLogger(TomP2PNode.class);
|
||||||
|
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
|
private String appName;
|
||||||
private final Boolean useDiskStorage;
|
private final Boolean useDiskStorage;
|
||||||
private MessageBroker messageBroker;
|
private MessageBroker messageBroker;
|
||||||
|
|
||||||
|
@ -94,8 +95,10 @@ public class TomP2PNode {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TomP2PNode(BootstrappedPeerFactory bootstrappedPeerFactory,
|
public TomP2PNode(BootstrappedPeerFactory bootstrappedPeerFactory,
|
||||||
|
@Named("appName") String appName,
|
||||||
@Named("useDiskStorage") Boolean useDiskStorage) {
|
@Named("useDiskStorage") Boolean useDiskStorage) {
|
||||||
this.bootstrappedPeerFactory = bootstrappedPeerFactory;
|
this.bootstrappedPeerFactory = bootstrappedPeerFactory;
|
||||||
|
this.appName = appName;
|
||||||
this.useDiskStorage = useDiskStorage;
|
this.useDiskStorage = useDiskStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +394,7 @@ public class TomP2PNode {
|
||||||
|
|
||||||
private void useDiscStorage(boolean useDiscStorage) {
|
private void useDiscStorage(boolean useDiscStorage) {
|
||||||
if (useDiscStorage) {
|
if (useDiscStorage) {
|
||||||
File path = new File(AppDirectory.dir().toFile() + "/tomP2P");
|
File path = new File(AppDirectory.dir(appName).toFile() + "/tomP2P");
|
||||||
if (!path.exists()) {
|
if (!path.exists()) {
|
||||||
boolean created = path.mkdir();
|
boolean created = path.mkdir();
|
||||||
if (!created)
|
if (!created)
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class Persistence {
|
||||||
|
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final File storageFile;
|
private final File storageFile;
|
||||||
|
private String appName;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -64,8 +65,9 @@ public class Persistence {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Persistence(@Named("appName") String appName) {
|
public Persistence(@Named("appName") String appName) {
|
||||||
this.prefix = appName + "_pref";
|
this.appName = appName;
|
||||||
this.storageFile = FileUtil.getFile(prefix, "ser");
|
this.prefix = appName + "_pref";
|
||||||
|
this.storageFile = FileUtil.getFile(appName, prefix, "ser");
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -218,7 +220,7 @@ public class Persistence {
|
||||||
FileOutputStream fileOutputStream = null;
|
FileOutputStream fileOutputStream = null;
|
||||||
ObjectOutputStream objectOutputStream = null;
|
ObjectOutputStream objectOutputStream = null;
|
||||||
try {
|
try {
|
||||||
tempFile = FileUtil.getTempFile(prefix);
|
tempFile = FileUtil.getTempFile(appName, prefix);
|
||||||
|
|
||||||
// Don't use auto closeable resources in try() as we would need too many try/catch clauses (for tempFile)
|
// Don't use auto closeable resources in try() as we would need too many try/catch clauses (for tempFile)
|
||||||
// and we need to close it
|
// and we need to close it
|
||||||
|
|
|
@ -31,9 +31,10 @@ import lighthouse.files.AppDirectory;
|
||||||
|
|
||||||
public class ConfigLoader {
|
public class ConfigLoader {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ConfigLoader.class);
|
private static final Logger log = LoggerFactory.getLogger(ConfigLoader.class);
|
||||||
private static final String configFilePath = AppDirectory.dir() + "/bitsquare.conf";
|
private static String configFilePath;
|
||||||
|
|
||||||
public static Properties loadConfig() {
|
public static Properties loadConfig(String appName) {
|
||||||
|
configFilePath = AppDirectory.dir(appName) + "/bitsquare.conf";
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
|
|
||||||
// load default properties from class path
|
// load default properties from class path
|
||||||
|
|
|
@ -30,12 +30,12 @@ import lighthouse.files.AppDirectory;
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
||||||
|
|
||||||
public static File getFile(String name, String suffix) {
|
public static File getFile(String appName, String name, String suffix) {
|
||||||
return new File(AppDirectory.dir().toFile(), name + "." + suffix);
|
return new File(AppDirectory.dir(appName).toFile(), name + "." + suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getTempFile(String prefix) throws IOException {
|
public static File getTempFile(String appName, String prefix) throws IOException {
|
||||||
return File.createTempFile("temp_" + prefix, null, AppDirectory.dir().toFile());
|
return File.createTempFile("temp_" + prefix, null, AppDirectory.dir(appName).toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTempFileToFile(File tempFile, File file) throws IOException {
|
public static void writeTempFileToFile(File tempFile, File file) throws IOException {
|
||||||
|
|
|
@ -50,9 +50,7 @@ public class AppDirectory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Path initAppDir(String appName) throws IOException {
|
public static Path initAppDir(String appName) throws IOException {
|
||||||
AppDirectory.appName = appName;
|
Path dir = dir(appName);
|
||||||
|
|
||||||
Path dir = dir();
|
|
||||||
if (!Files.exists(dir))
|
if (!Files.exists(dir))
|
||||||
Files.createDirectory(dir);
|
Files.createDirectory(dir);
|
||||||
else if (!Files.isWritable(dir))
|
else if (!Files.isWritable(dir))
|
||||||
|
@ -60,11 +58,9 @@ public class AppDirectory {
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String appName = "";
|
|
||||||
|
|
||||||
private static Path dir;
|
private static Path dir;
|
||||||
|
|
||||||
public static Path dir() {
|
public static Path dir(String appName) {
|
||||||
if (dir == null)
|
if (dir == null)
|
||||||
return getUserDataDir(appName);
|
return getUserDataDir(appName);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue