Merge pull request #6527 from yonson2023/disk_space_warning

Warn user when free disk space is too low.
This commit is contained in:
Alejandro García 2023-01-24 16:17:11 +00:00 committed by GitHub
commit 74e1078318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 2 deletions

View File

@ -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"));

View File

@ -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<Boolean> 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();

View File

@ -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 \

View File

@ -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)));

View File

@ -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;