Przeglądaj źródła

bugfix: 修复seal重复导致读取checklist丢失的问题

JustryDeng 3 lat temu
rodzic
commit
be09dec132

+ 2 - 2
README.md

@@ -52,7 +52,7 @@
   <plugin>
       <groupId>com.idea-aedi</groupId>
       <artifactId>class-winter-maven-plugin</artifactId>
-      <version>2.8.3</version>
+      <version>2.8.4</version>
       <!-- 相关配置 -->
       <configuration>
           <!-- <finalName></finalName>-->
@@ -464,7 +464,7 @@ linux示例:tips='请不要直接使用混淆后的jar/war'</td>
       <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
-          <version>2.8.3</version>
+          <version>2.8.4</version>
           <relativePath/> <!-- lookup parent from repository -->
       </parent>
       <groupId>com.example</groupId>

+ 1 - 1
class-winter-core/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <groupId>com.idea-aedi</groupId>
         <artifactId>class-winter</artifactId>
-        <version>2.8.3</version>
+        <version>2.8.4</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 13 - 6
class-winter-core/src/main/java/winter/com/ideaaedi/classwinter/executor/DecryptExecutor.java

@@ -101,20 +101,27 @@ public class DecryptExecutor {
      * @return classLongName是否在(记录已加密类的)清单列表中
      */
     public static boolean checklistContain(String projectPath, String classLongName) {
-        // 如果当前projectPath的印章,用的是Cache.firstSealCache的话,那么此方法中获取checklist,也获取Cache.firstSealCache对应的checklist
-        projectPath = Cache.firstSealCache.equals(Cache.sealCache.get(projectPath)) ? Cache.firstSealProjectPath : projectPath;
+        // step1. 试着直接获取对应projectPath的checklist
         if (!checklist.containsKey(projectPath)) {
             byte[] checklistByte = IOUtil.readFileFromWorkbenchRoot(new File(projectPath),
                     Constant.ALREADY_ENCRYPTED_CLASS_CHECKLIST_CLASSES_SAVE_FILE);
-            if (checklistByte == null) {
-                Logger.debug(DecryptExecutor.class, "checklistByte is null. ");
-            } else {
+            if (checklistByte != null) {
                 String checklistContent = new String(checklistByte, StandardCharsets.UTF_8);
                 Logger.debug(DecryptExecutor.class, "checklistContent " + checklistContent);
                 checklist.put(projectPath, new HashSet<>(Arrays.asList(checklistContent.split(Constant.COMMA))));
             }
         }
-        return checklist.get(projectPath).contains(classLongName);
+        if (checklist.containsKey(projectPath)) {
+            return checklist.get(projectPath).contains(classLongName);
+        }
+    
+        // step2. 若当前projectPath与第一个projectPath使用相同的印章,那么使用第一个projectPath对应的checklist
+        if (Cache.firstSealCache.equals(Cache.sealCache.get(projectPath))) {
+            Set<String> firstChecklist = checklist.get(Cache.firstSealProjectPath);
+            checklist.put(projectPath, firstChecklist == null ? new HashSet<>() : firstChecklist);
+            return checklist.get(projectPath).contains(classLongName);
+        }
+        return false;
     }
     
     /**

+ 1 - 1
class-winter-maven-plugin/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <groupId>com.idea-aedi</groupId>
         <artifactId>class-winter</artifactId>
-        <version>2.8.3</version>
+        <version>2.8.4</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
pom.xml

@@ -9,7 +9,7 @@
     </modules>
     <groupId>com.idea-aedi</groupId>
     <artifactId>class-winter</artifactId>
-    <version>2.8.3</version>
+    <version>2.8.4</version>
 
     <!-- 配置项目的基础信息 -->
     <name>class-winter</name>