Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn user when free disk space is too low. #6527

Merged
merged 2 commits into from Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/java/bisq/core/app/BisqHeadlessApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ protected void setupHandlers() {
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"));
Expand Down
18 changes: 17 additions & 1 deletion core/src/main/java/bisq/core/app/BisqSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@

import javax.annotation.Nullable;

import static bisq.core.util.FormattingUtils.formatBytes;

@Slf4j
@Singleton
public class BisqSetup {
Expand Down Expand Up @@ -162,7 +164,7 @@ default void onRequestWalletPassword() {
filterWarningHandler, displaySecurityRecommendationHandler, displayLocalhostHandler,
wrongOSArchitectureHandler, displaySignedByArbitratorHandler,
displaySignedByPeerHandler, displayPeerLimitLiftedHandler, displayPeerSignerHandler,
rejectedTxErrorMessageHandler;
rejectedTxErrorMessageHandler, diskSpaceWarningHandler;
@Setter
@Nullable
private Consumer<Boolean> displayTorNetworkSettingsHandler;
Expand Down Expand Up @@ -462,8 +464,10 @@ private void initWallet() {
walletPasswordHandler,
() -> {
if (allBasicServicesInitialized) {
// the following are called each time a block is received
checkForLockedUpFunds();
checkForInvalidMakerFeeTxs();
checkFreeDiskSpace();
}
},
() -> walletInitialized.set(true));
Expand Down Expand Up @@ -547,6 +551,18 @@ private void checkForInvalidMakerFeeTxs() {
});
}

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();
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -3202,6 +3201,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 \
Expand Down
8 changes: 8 additions & 0 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -392,6 +393,13 @@ private void setupHandlers() {
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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static void queueForDisplay(Popup popup) {
displayNext();
}

public static boolean isNoPopupDisplayed() {
return displayedPopup == null;
}

public static void onHidden(Popup popup) {
if (displayedPopup == null || displayedPopup == popup) {
displayedPopup = null;
Expand Down