From 651ce8a3f36bc2f2becd274b549985df24d59a5f Mon Sep 17 00:00:00 2001 From: Bryant Date: Thu, 31 Oct 2019 16:11:14 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-23486=20=E4=BF=AE=E5=A4=8Dbug=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=9B=B4=E6=94=B9=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../update/actions/RecoverForDesigner.java | 32 ++++++++++++++----- .../update/ui/dialog/RestoreResultDialog.java | 3 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java index 92493430f..dc26efc59 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -1,6 +1,7 @@ package com.fr.design.update.actions; import com.fr.decision.update.backup.Recover; +import com.fr.decision.update.backup.RecoverPathManager; import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.exception.UpdateException; import com.fr.design.mainframe.DesignerContext; @@ -40,7 +41,7 @@ public class RecoverForDesigner implements Recover { public boolean backup() { //jar包备份文件的目录为"backup/"+jar包当前版本号 String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); - String envHome = StableUtils.pathJoin(installHome, UpdateConstants.WEBAPPS, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); + String envHome = RecoverPathManager.getInstance().getEnvHome(); backupFilesFromInstallEnv(envHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir); try { @@ -63,10 +64,18 @@ public class RecoverForDesigner implements Recover { private void backupFilesFromInstallEnv(String envHome, String todayBackupDir) { try { - CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH))); - CommonIOUtils.copyFilesInDirByPath( - StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME), - StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + File file = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + CommonUtils.mkdirs(file); + file = new File(StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME)); + File[] files = file.listFiles(); + File dir = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + if (files != null) { + for (File file1 : files) { + if (file1.getName().startsWith(UpdateConstants.FINE) && file1.getName().endsWith(UpdateConstants.JAR_FILE_SUFFIX)) { + CommonIOUtils.copy(file1, dir); + } + } + } } catch (IOException e) { UpdateException exception = new UpdateException(e.getMessage()); FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed"); @@ -76,9 +85,16 @@ public class RecoverForDesigner implements Recover { private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { try { CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH))); - CommonIOUtils.copyFilesInDirByPath( - StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), - StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); + File file = new File(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME)); + File[] files = file.listFiles(); + File dir = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); + if (files != null) { + for (File file1 : files) { + if (file1.getName().startsWith(UpdateConstants.FINE) || file1.getName().contains(UpdateConstants.ASPECTJRT)) { + CommonIOUtils.copy(file, dir); + } + } + } } catch (IOException e) { UpdateException exception = new UpdateException(e.getMessage()); FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed"); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java index 225ab1312..d94a93c71 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java @@ -10,7 +10,6 @@ import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import com.fr.workspace.WorkContext; import javax.swing.AbstractAction; import javax.swing.BorderFactory; @@ -206,7 +205,7 @@ public class RestoreResultDialog extends JDialog { } private void filesToDelete(String installHome, List list) { - String envHome = WorkContext.getCurrent().getPath(); + String envHome = StableUtils.pathJoin(installHome, UpdateConstants.WEBAPPS, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); File installEnv = new File(StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME)); File[] files = installEnv.listFiles(); if (files != null) {