diff --git a/core/src/main/java/bisq/core/support/dispute/mediation/FileTransferSender.java b/core/src/main/java/bisq/core/support/dispute/mediation/FileTransferSender.java index 690da04eb51..e15e94c6490 100644 --- a/core/src/main/java/bisq/core/support/dispute/mediation/FileTransferSender.java +++ b/core/src/main/java/bisq/core/support/dispute/mediation/FileTransferSender.java @@ -23,6 +23,7 @@ import bisq.common.UserThread; import bisq.common.config.Config; +import bisq.common.util.Utilities; import com.google.protobuf.ByteString; @@ -62,11 +63,15 @@ public FileTransferSender(NetworkNode networkNode, String traderRole, @Nullable FileTransferSession.FtpCallback callback) { super(networkNode, peerNodeAddress, tradeId, traderId, traderRole, callback); - zipFilePath = Config.appDataDir() + FileSystems.getDefault().getSeparator() + zipId + ".zip"; + zipFilePath = Utilities.getUserDataDir() + FileSystems.getDefault().getSeparator() + zipId + ".zip"; updateProgress(); } public void createZipFileToSend() { + createZipFileOfLogs(zipFilePath, zipId, fullTradeId); + } + + public static void createZipFileOfLogs(String zipFilePath, String zipId, String fullTradeId) { try { Map env = new HashMap<>(); env.put("create", "true"); @@ -80,6 +85,7 @@ public void createZipFileToSend() { try { // always include bisq.log; and other .log files if they contain the TradeId if (externalTxtFile.getFileName().toString().equals("bisq.log") || + (fullTradeId == null && externalTxtFile.getFileName().toString().matches(".*.log")) || (externalTxtFile.getFileName().toString().matches(".*.log") && doesFileContainKeyword(externalTxtFile.toFile(), fullTradeId))) { Path pathInZipfile = zipfs.getPath(zipId + "/" + externalTxtFile.getFileName().toString()); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 1f1e41dc2e2..9808ff34575 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1849,6 +1849,7 @@ account.backup.backupNow=Backup now (backup is not encrypted!) account.backup.appDir=Application data directory account.backup.openDirectory=Open directory account.backup.openLogFile=Open Log file +account.backup.zipLogFiles=Zip Log files account.backup.success=Backup successfully saved at:\n{0} account.backup.directoryNotAccessible=The directory you have chosen is not accessible. {0} diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java b/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java index 14a30c820cc..433b772c089 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/backup/BackupView.java @@ -23,12 +23,14 @@ import bisq.desktop.util.Layout; import bisq.core.locale.Res; +import bisq.core.support.dispute.mediation.FileTransferSender; import bisq.core.user.Preferences; import bisq.common.config.Config; import bisq.common.file.FileUtil; import bisq.common.persistence.PersistenceManager; import bisq.common.util.Tuple2; +import bisq.common.util.Tuple3; import bisq.common.util.Utilities; import javax.inject.Inject; @@ -43,6 +45,7 @@ import java.text.SimpleDateFormat; +import java.nio.file.FileSystems; import java.nio.file.Paths; import java.io.File; @@ -52,10 +55,7 @@ import javax.annotation.Nullable; -import static bisq.desktop.util.FormBuilder.add2Buttons; -import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static bisq.desktop.util.FormBuilder.addInputTextField; -import static bisq.desktop.util.FormBuilder.addTitledGroupBg; +import static bisq.desktop.util.FormBuilder.*; @FxmlView public class BackupView extends ActivatableView { @@ -64,7 +64,7 @@ public class BackupView extends ActivatableView { private final Preferences preferences; private Button selectBackupDir, backupNow; private TextField backUpLocationTextField; - private Button openDataDirButton, openLogsButton; + private Button openDataDirButton, openLogsButton, zipLogsButton; private ChangeListener backUpLocationTextFieldFocusListener; @@ -102,11 +102,15 @@ public void initialize() { addTitledGroupBg(root, ++gridRow, 2, Res.get("account.backup.appDir"), Layout.GROUP_DISTANCE); - final Tuple2 applicationDataDirTuple2 = add2Buttons(root, gridRow, Res.get("account.backup.openDirectory"), - Res.get("account.backup.openLogFile"), Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE, false); + final Tuple3 applicationDataDirTuple2 = add3Buttons(root, gridRow, + Res.get("account.backup.openDirectory"), + Res.get("account.backup.openLogFile"), + Res.get("account.backup.zipLogFiles"), + Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE); openDataDirButton = applicationDataDirTuple2.first; openLogsButton = applicationDataDirTuple2.second; + zipLogsButton = applicationDataDirTuple2.third; } @Override @@ -151,6 +155,19 @@ protected void activate() { }); } }); + zipLogsButton.setOnAction(event -> { + String zipId = "BisqLogsArchive_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String zipFilePath = Utilities.getSystemHomeDirectory() + FileSystems.getDefault().getSeparator() + zipId + ".zip"; + String tradeId = null; + FileTransferSender.createZipFileOfLogs(zipFilePath, zipId, tradeId); + try { + Utilities.openFile(new File(Utilities.getSystemHomeDirectory())); + } catch (IOException e) { + e.printStackTrace(); + log.error(e.getMessage()); + showWrongPathWarningAndReset(e); + } + }); } private void openFileOrShowWarning(Button button, File dataDir) {