mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-18 14:55:53 -04:00
Add clean param to clean data directory #291
This commit is contained in:
parent
ea98a15406
commit
970cd776f3
@ -25,6 +25,8 @@ import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.util.Utilities;
|
||||
import io.bitsquare.util.spring.JOptCommandLinePropertySource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import java.util.Properties;
|
||||
@ -38,6 +40,7 @@ import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.ResourcePropertySource;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -45,6 +48,7 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
|
||||
public static final String APP_VERSION_KEY = "app.version";
|
||||
|
||||
public static final String USER_DATA_CLEAN_DIR_KEY = "user.data.clean.dir";
|
||||
public static final String USER_DATA_DIR_KEY = "user.data.dir";
|
||||
public static final String DEFAULT_USER_DATA_DIR = defaultUserDataDir();
|
||||
|
||||
@ -90,6 +94,12 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
} catch (Exception ex) {
|
||||
throw new BitsquareException(ex);
|
||||
}
|
||||
|
||||
boolean cleanUserDataDir = commandLineProperties.containsProperty(USER_DATA_CLEAN_DIR_KEY) &&
|
||||
commandLineProperties.getProperty(USER_DATA_CLEAN_DIR_KEY).equals("true");
|
||||
if (cleanUserDataDir) {
|
||||
FileSystemUtils.deleteRecursively(new File(appDataDir));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,6 +41,9 @@ public class BitsquareAppMain extends BitsquareExecutable {
|
||||
protected void customizeOptionParsing(OptionParser parser) {
|
||||
parser.accepts(USER_DATA_DIR_KEY, description("User data directory", DEFAULT_USER_DATA_DIR))
|
||||
.withRequiredArg();
|
||||
parser.accepts(USER_DATA_CLEAN_DIR_KEY, description("Clean user data directory", false))
|
||||
.withRequiredArg()
|
||||
.ofType(boolean.class);
|
||||
parser.accepts(APP_NAME_KEY, description("Application name", DEFAULT_APP_NAME))
|
||||
.withRequiredArg();
|
||||
parser.accepts(APP_DATA_DIR_KEY, description("Application data directory", DEFAULT_APP_DATA_DIR))
|
||||
|
Loading…
x
Reference in New Issue
Block a user