Browse Source

Turn off repository backups by default.

They can be re-enabled by setting "repositoryBackupInterval" to a
non-zero value in settings.json. Note the value is in milliseconds!
split-DB
catbref 5 years ago
parent
commit
6c8e96daae
  1. 11
      src/main/java/org/qortal/controller/Controller.java
  2. 6
      src/main/java/org/qortal/settings/Settings.java

11
src/main/java/org/qortal/controller/Controller.java

@ -104,7 +104,6 @@ public class Controller extends Thread {
private static final Object shutdownLock = new Object();
private static final String repositoryUrlTemplate = "jdbc:hsqldb:file:%s" + File.separator + "blockchain;create=true;hsqldb.full_log_replay=true";
private static final long ARBITRARY_REQUEST_TIMEOUT = 5 * 1000L; // ms
private static final long REPOSITORY_BACKUP_PERIOD = 123 * 60 * 1000L; // ms
private static final long NTP_PRE_SYNC_CHECK_PERIOD = 5 * 1000L; // ms
private static final long NTP_POST_SYNC_CHECK_PERIOD = 5 * 60 * 1000L; // ms
private static final long DELETE_EXPIRED_INTERVAL = 5 * 60 * 1000L; // ms
@ -127,7 +126,7 @@ public class Controller extends Thread {
private volatile BlockData chainTip = null;
private long repositoryBackupTimestamp = startTime + REPOSITORY_BACKUP_PERIOD; // ms
private long repositoryBackupTimestamp = startTime; // ms
private long ntpCheckTimestamp = startTime; // ms
private long deleteExpiredTimestamp = startTime + DELETE_EXPIRED_INTERVAL; // ms
private long onlineAccountsTasksTimestamp = startTime + ONLINE_ACCOUNTS_TASKS_INTERVAL; // ms
@ -388,6 +387,8 @@ public class Controller extends Thread {
public void run() {
Thread.currentThread().setName("Controller");
final long repositoryBackupInterval = Settings.getInstance().getRepositoryBackupInterval();
try {
while (!isStopping) {
// Maybe update SysTray
@ -428,9 +429,9 @@ public class Controller extends Thread {
final long requestMinimumTimestamp = now - ARBITRARY_REQUEST_TIMEOUT;
arbitraryDataRequests.entrySet().removeIf(entry -> entry.getValue().getC() < requestMinimumTimestamp);
// Give repository a chance to backup
if (now >= repositoryBackupTimestamp) {
repositoryBackupTimestamp = now + REPOSITORY_BACKUP_PERIOD;
// Give repository a chance to backup (if enabled)
if (repositoryBackupInterval > 0 && now >= repositoryBackupTimestamp + repositoryBackupInterval) {
repositoryBackupTimestamp = now + repositoryBackupInterval;
if (Settings.getInstance().getShowBackupNotification())
SysTray.getInstance().showMessage(Translator.INSTANCE.translate("SysTray", "DB_BACKUP"),

6
src/main/java/org/qortal/settings/Settings.java

@ -71,6 +71,8 @@ public class Settings {
private int maxTransactionTimestampFuture = 24 * 60 * 60 * 1000; // milliseconds
/** Whether we check, fetch and install auto-updates */
private boolean autoUpdateEnabled = true;
/** How long between repository backups (ms), or 0 if disabled. */
private long repositoryBackupInterval = 0; // ms
/** Whether to show a notification when we backup repository. */
private boolean showBackupNotification = false;
@ -371,6 +373,10 @@ public class Settings {
return this.testNtpOffset;
}
public long getRepositoryBackupInterval() {
return this.repositoryBackupInterval;
}
public boolean getShowBackupNotification() {
return this.showBackupNotification;
}

Loading…
Cancel
Save