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

Reset Tor directory when a new release is downloaded. #6275

Merged
merged 1 commit into from Jun 30, 2022
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
2 changes: 1 addition & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ displayUpdateDownloadWindow.verify.failed=Verification failed.\n\
Please download and verify manually at [HYPERLINK:https://bisq.network/downloads]
displayUpdateDownloadWindow.success=The new version has been successfully downloaded and the signature verified.\n\n\
Please open the download directory, shut down the application and install the new version.
displayUpdateDownloadWindow.download.openDir=Open download directory
displayUpdateDownloadWindow.download.openDir=Open download directory and shut down

disputeSummaryWindow.title=Summary
disputeSummaryWindow.openDate=Ticket opening date
Expand Down
14 changes: 14 additions & 0 deletions desktop/src/main/java/bisq/desktop/app/BisqAppMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

import bisq.core.app.AvoidStandbyModeService;
import bisq.core.app.BisqExecutable;
import bisq.core.app.TorSetup;
import bisq.core.user.Cookie;
import bisq.core.user.CookieKey;
import bisq.core.user.User;

import bisq.common.UserThread;
import bisq.common.app.AppModule;
Expand Down Expand Up @@ -125,6 +129,16 @@ protected void setupAvoidStandbyMode() {

@Override
protected void startApplication() {
Cookie cookie = injector.getInstance(User.class).getCookie();
cookie.getAsOptionalBoolean(CookieKey.CLEAN_TOR_DIR_AT_RESTART).ifPresent(wasCleanTorDirSet -> {
if (wasCleanTorDirSet) {
injector.getInstance(TorSetup.class).cleanupTorFiles(() -> {
log.info("Tor directory reset");
cookie.remove(CookieKey.CLEAN_TOR_DIR_AT_RESTART);
}, log::error);
}
});

// We need to be in user thread! We mapped at launchApplication already. Once
// the UI is ready we get onApplicationStarted called and start the setup there.
application.startApplication(this::onApplicationStarted);
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ private void setupHandlers() {
.onClose(() -> BisqApp.getShutDownHandler().run())
.show());

bisqSetup.setDisplayUpdateHandler((alert, key) -> new DisplayUpdateDownloadWindow(alert, config)
bisqSetup.setDisplayUpdateHandler((alert, key) -> new DisplayUpdateDownloadWindow(alert, config, user)
.actionButtonText(Res.get("displayUpdateDownloadWindow.button.downloadLater"))
.onAction(() -> {
preferences.dontShowAgain(key, false); // update later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package bisq.desktop.main.overlays.windows.downloadupdate;

import bisq.desktop.app.BisqApp;
import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.BusyAnimation;
Expand All @@ -25,7 +26,10 @@

import bisq.core.alert.Alert;
import bisq.core.locale.Res;
import bisq.core.user.CookieKey;
import bisq.core.user.User;

import bisq.common.UserThread;
import bisq.common.config.Config;
import bisq.common.util.Utilities;

Expand Down Expand Up @@ -72,6 +76,7 @@
public class DisplayUpdateDownloadWindow extends Overlay<DisplayUpdateDownloadWindow> {
private final Alert alert;
private final Config config;
private final User user;
private Optional<DownloadTask> downloadTaskOptional;
private VerifyTask verifyTask;
private ProgressBar progressBar;
Expand All @@ -82,9 +87,10 @@ public class DisplayUpdateDownloadWindow extends Overlay<DisplayUpdateDownloadWi
// Public API
///////////////////////////////////////////////////////////////////////////////////////////

public DisplayUpdateDownloadWindow(Alert alert, Config config) {
public DisplayUpdateDownloadWindow(Alert alert, Config config, User user) {
this.alert = alert;
this.config = config;
this.user = user;
this.type = Type.Attention;
}

Expand Down Expand Up @@ -254,12 +260,16 @@ private void addContent() {
if (verifyResults == null || verifyResults.isEmpty() || verifyFailed.isPresent()) {
showErrorMessage(downloadButton, statusLabel, Res.get("displayUpdateDownloadWindow.verify.failed"));
} else {
// We set a flag to clear tor cache files at re-start. We cannot clear it now as Tor is used and
// that can cause problems.
user.getCookie().putAsBoolean(CookieKey.CLEAN_TOR_DIR_AT_RESTART, true);
verifiedSigLabel.getStyleClass().add("success-text");
new Popup().feedback(Res.get("displayUpdateDownloadWindow.success"))
.actionButtonText(Res.get("displayUpdateDownloadWindow.download.openDir"))
.onAction(() -> {
try {
Utilities.openFile(new File(Utilities.getDownloadOfHomeDir()));
BisqApp.getShutDownHandler().run();
doClose();
} catch (IOException e2) {
log.error(e2.getMessage());
Expand Down