Browse Source

REPORT-40472 设计器内还原到历史版本后备份的文件夹没有删除

feature/big-screen
bryant 4 years ago
parent
commit
e1e3f37638
  1. 21
      designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java
  2. 5
      designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java

21
designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java

@ -27,9 +27,26 @@ public class UpdateFileUtils {
List<String> versions = new ArrayList<>(); List<String> versions = new ArrayList<>();
if (versionBackup != null) { if (versionBackup != null) {
for (File file : versionBackup) { for (File file : versionBackup) {
if (file.isDirectory() && file.length() > 0) { boolean canBackup = true;
versions.add(file.getName()); if (file.isDirectory()) {
File[] libs = file.listFiles();
if (libs == null || libs.length == 0) {
canBackup = false;
} else { } else {
for (File lib : libs) {
if (lib.isDirectory()) {
File[] jars = lib.listFiles();
if (jars == null || jars.length == 0) {
canBackup = false;
}
}
}
}
if (canBackup) {
versions.add(file.getName());
}
}
if (!canBackup) {
StableUtils.deleteFile(file); StableUtils.deleteFile(file);
} }
} }

5
designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java

@ -15,8 +15,9 @@ public class UpdateFileUtilsTest {
@Test @Test
public void testListFilteredFiles() { public void testListFilteredFiles() {
StableUtils.mkdirs(new File("home/backup/version/lib/jars"));
String[] result = UpdateFileUtils.listFilteredFiles("home", "backup"); String[] result = UpdateFileUtils.listFilteredFiles("home", "backup");
Assert.assertEquals(0, result.length); Assert.assertEquals(1, result.length);
StableUtils.deleteFile(new File(StableUtils.pathJoin("home"))); StableUtils.deleteFile(new File("home"));
} }
} }

Loading…
Cancel
Save