Browse Source

Use better check if restore is started

pull/20/head
Kristijan Mitrovic 4 years ago
parent
commit
3f72132fd8
2 changed files with 4 additions and 1 deletions
  1. +1
    -1
      bubble-server/src/main/java/bubble/server/BubbleConfiguration.java
  2. +3
    -0
      bubble-server/src/main/java/bubble/service/backup/RestoreService.java

+ 1
- 1
bubble-server/src/main/java/bubble/server/BubbleConfiguration.java View File

@@ -307,7 +307,7 @@ public class BubbleConfiguration extends PgRestServerConfiguration
{TAG_RESTORE_MODE, thisNetwork == null {TAG_RESTORE_MODE, thisNetwork == null
? false ? false
: thisNetwork.getState().equals(BubbleNetworkState.restoring) : thisNetwork.getState().equals(BubbleNetworkState.restoring)
&& !restoreService.getRestoreKeys().exists(thisNetwork.getUuid())},
&& !restoreService.isRestoreStarted(thisNetwork.getUuid())},
{TAG_SSL_PORT, getDefaultSslPort()}, {TAG_SSL_PORT, getDefaultSslPort()},
{TAG_SUPPORT, getSupport()}, {TAG_SUPPORT, getSupport()},
{TAG_SECURITY_LEVELS, DeviceSecurityLevel.values()} {TAG_SECURITY_LEVELS, DeviceSecurityLevel.values()}


+ 3
- 0
bubble-server/src/main/java/bubble/service/backup/RestoreService.java View File

@@ -35,6 +35,7 @@ import static org.cobbzilla.util.io.FileUtil.*;
import static org.cobbzilla.util.json.JsonUtil.json; import static org.cobbzilla.util.json.JsonUtil.json;
import static org.cobbzilla.util.security.CryptStream.BUFFER_SIZE; import static org.cobbzilla.util.security.CryptStream.BUFFER_SIZE;
import static org.cobbzilla.wizard.cache.redis.RedisService.EX; import static org.cobbzilla.wizard.cache.redis.RedisService.EX;
import static org.cobbzilla.wizard.cache.redis.RedisService.LOCK_SUFFIX;


@Service @Slf4j @Service @Slf4j
public class RestoreService { public class RestoreService {
@@ -64,6 +65,8 @@ public class RestoreService {


public boolean isValidRestoreKey(String restoreKey) { return getRestoreKeys().exists(restoreKey); } public boolean isValidRestoreKey(String restoreKey) { return getRestoreKeys().exists(restoreKey); }


public boolean isRestoreStarted(String networkUuid) { return getRestoreKeys().exists(networkUuid + LOCK_SUFFIX); }

public boolean restore(String restoreKey, BubbleBackup backup) { public boolean restore(String restoreKey, BubbleBackup backup) {
final String thisNodeUuid = configuration.getThisNode().getUuid(); final String thisNodeUuid = configuration.getThisNode().getUuid();
final String thisNetworkUuid = configuration.getThisNode().getNetwork(); final String thisNetworkUuid = configuration.getThisNode().getNetwork();


Loading…
Cancel
Save