Browse Source
Merge in DESIGN/design from ~BRYANT/design:release/10.0 to release/10.0 * commit '9e8009e3193b3763eb2a33576fef2825bb72da82': REPORT-40472 设计器内还原到历史版本后备份的文件夹没有删除 REPORT-40472 设计器内还原到历史版本后备份的文件夹没有删除feature/big-screen
Bryant
4 years ago
6 changed files with 92 additions and 13 deletions
@ -0,0 +1,50 @@ |
|||||||
|
package com.fr.design.update.factory; |
||||||
|
|
||||||
|
import com.fr.decision.update.data.UpdateConstants; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
|
||||||
|
import java.io.File;; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bryant |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bryant on 2020-09-29 |
||||||
|
*/ |
||||||
|
public class UpdateFileFactory { |
||||||
|
|
||||||
|
private UpdateFileFactory() { |
||||||
|
} |
||||||
|
|
||||||
|
public static File[] getBackupVersions() { |
||||||
|
File[] versions = null; |
||||||
|
try { |
||||||
|
File backupDir = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR)); |
||||||
|
StableUtils.mkdirs(backupDir); |
||||||
|
versions = backupDir.listFiles(); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return versions; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isBackupVersionsValid(String version) { |
||||||
|
boolean designerValid = false; |
||||||
|
boolean envValid = false; |
||||||
|
try { |
||||||
|
File designerLib = new File(StableUtils.pathJoin(version, UpdateConstants.DESIGNERBACKUPPATH)); |
||||||
|
File[] jars = designerLib.listFiles(); |
||||||
|
if (jars != null && jars.length > 0) { |
||||||
|
designerValid = true; |
||||||
|
} |
||||||
|
File envLib = new File(StableUtils.pathJoin(version, UpdateConstants.BACKUPPATH)); |
||||||
|
jars = envLib.listFiles(); |
||||||
|
if (jars != null && jars.length > 0) { |
||||||
|
envValid = true; |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return designerValid && envValid; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.fr.design.update.factory; |
||||||
|
|
||||||
|
import com.fr.decision.update.data.UpdateConstants; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
|
||||||
|
public class UpdateFileFactoryTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetBackupVersions() { |
||||||
|
Assert.assertEquals(0, UpdateFileFactory.getBackupVersions().length); |
||||||
|
File backupDir = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR)); |
||||||
|
StableUtils.deleteFile(backupDir); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testIsBackupVersionsValid() { |
||||||
|
File des = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.BACKUPPATH, "test")); |
||||||
|
File env = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.DESIGNERBACKUPPATH, "test")); |
||||||
|
StableUtils.mkdirs(des); |
||||||
|
StableUtils.mkdirs(env); |
||||||
|
Assert.assertTrue(UpdateFileFactory.isBackupVersionsValid(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test"))); |
||||||
|
StableUtils.deleteFile(new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR))); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue