diff --git a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java index a6fcca5401..2d470403c3 100644 --- a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java +++ b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java @@ -78,6 +78,7 @@ public class BisqHeadlessApp implements HeadlessApp { bisqSetup.setDisplayTorNetworkSettingsHandler(show -> log.info("onDisplayTorNetworkSettingsHandler: show={}", show)); bisqSetup.setSpvFileCorruptedHandler(msg -> log.error("onSpvFileCorruptedHandler: msg={}", msg)); bisqSetup.setChainFileLockedExceptionHandler(msg -> log.error("onChainFileLockedExceptionHandler: msg={}", msg)); + bisqSetup.setDiskSpaceWarningHandler(msg -> log.error("onDiskSpaceWarningHandler: msg={}", msg)); bisqSetup.setLockedUpFundsHandler(msg -> log.info("onLockedUpFundsHandler: msg={}", msg)); bisqSetup.setShowFirstPopupIfResyncSPVRequestedHandler(() -> log.info("onShowFirstPopupIfResyncSPVRequestedHandler")); bisqSetup.setRequestWalletPasswordHandler(aesKeyHandler -> log.info("onRequestWalletPasswordHandler")); diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 48a4d9371e..2b6ba038d5 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -107,6 +107,8 @@ import lombok.extern.slf4j.Slf4j; import javax.annotation.Nullable; +import static bisq.core.util.FormattingUtils.formatBytes; + @Slf4j @Singleton public class BisqSetup { @@ -162,7 +164,7 @@ public class BisqSetup { filterWarningHandler, displaySecurityRecommendationHandler, displayLocalhostHandler, wrongOSArchitectureHandler, displaySignedByArbitratorHandler, displaySignedByPeerHandler, displayPeerLimitLiftedHandler, displayPeerSignerHandler, - rejectedTxErrorMessageHandler; + rejectedTxErrorMessageHandler, diskSpaceWarningHandler; @Setter @Nullable private Consumer displayTorNetworkSettingsHandler; @@ -462,8 +464,10 @@ public class BisqSetup { walletPasswordHandler, () -> { if (allBasicServicesInitialized) { + // the following are called each time a block is received checkForLockedUpFunds(); checkForInvalidMakerFeeTxs(); + checkFreeDiskSpace(); } }, () -> walletInitialized.set(true)); @@ -547,6 +551,18 @@ public class BisqSetup { }); } + private void checkFreeDiskSpace() { + long TWO_GIGABYTES = 2147483648L; + long usableSpace = new File(Config.appDataDir(), VERSION_FILE_NAME).getUsableSpace(); + if (usableSpace < TWO_GIGABYTES) { + String message = Res.get("popup.warning.diskSpace", formatBytes(usableSpace), formatBytes(TWO_GIGABYTES)); + log.warn(message); + if (diskSpaceWarningHandler != null) { + diskSpaceWarningHandler.accept(message); + } + } + } + @Nullable public static String getLastBisqVersion() { File versionFile = getVersionFile(); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 200256720f..0f67ac43c7 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1,4 +1,3 @@ -# Keep display strings organized by domain # Naming convention: We use camelCase and dot separated name spaces. # Use as many sub spaces as required to make the structure clear, but as little as possible. # E.g.: [main-view].[component].[description] @@ -3204,6 +3203,10 @@ popup.warning.openOfferWithInvalidMakerFeeTx=The maker fee transaction for offer Please go to \"Settings/Network info\" and do a SPV resync.\n\ For further help please contact the Bisq support channel at the Bisq Matrix Space. +popup.warning.diskSpace=You have less than 2 GB free disk space left.\n\ + Free space={0}, required space={1}.\n\n\ + Please free up some disk space to continue running Bisq. + popup.info.securityDepositInfo=To ensure both traders follow the trade protocol, both traders need to pay a security \ deposit.\n\nThis deposit is kept in your trade wallet until your trade has been successfully completed, and then it's \ refunded to you.\n\nPlease note: if you're creating a new offer, Bisq needs to be running for another trader to take \ diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index 4c132613c3..cf96b23d68 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -27,6 +27,7 @@ import bisq.desktop.main.overlays.Overlay; import bisq.desktop.main.overlays.notifications.Notification; import bisq.desktop.main.overlays.notifications.NotificationCenter; import bisq.desktop.main.overlays.popups.Popup; +import bisq.desktop.main.overlays.popups.PopupManager; import bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow; import bisq.desktop.main.overlays.windows.TacWindow; import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow; @@ -392,6 +393,13 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { bisqSetup.setChainFileLockedExceptionHandler(msg -> new Popup().warning(msg) .useShutDownButton() .show()); + + bisqSetup.setDiskSpaceWarningHandler(msg -> { + if (PopupManager.isNoPopupDisplayed()) { + new Popup().warning(msg).show(); + } + }); + bisqSetup.setLockedUpFundsHandler(msg -> { // repeated popups of the same message text can be stopped by selecting the "Dont show again" checkbox String key = Hex.encode(Hash.getSha256Ripemd160hash(msg.getBytes(Charsets.UTF_8))); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/popups/PopupManager.java b/desktop/src/main/java/bisq/desktop/main/overlays/popups/PopupManager.java index 41d9415b67..f20234834b 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/popups/PopupManager.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/popups/PopupManager.java @@ -40,6 +40,10 @@ public class PopupManager { displayNext(); } + public static boolean isNoPopupDisplayed() { + return displayedPopup == null; + } + public static void onHidden(Popup popup) { if (displayedPopup == null || displayedPopup == popup) { displayedPopup = null;