Forráskód Böngészése

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

(cherry picked from commit 1e3c28839cf1f88dab3034ff0a93302049d069de)
JustryDeng 3 éve
szülő
commit
87236d19af

+ 5 - 4
class-winter-core/src/main/java/winter/com/ideaaedi/classwinter/executor/DecryptExecutor.java

@@ -328,9 +328,10 @@ public class DecryptExecutor {
     private static char[] obtainAutoGeneratedPwdWhileEncrypt(String projectPath, String classWinterInfoDir) {
         // 项目本身
         if (classWinterInfoDir.equals(Constant.DEFAULT_ENCRYPTED_BASE_SAVE_DIR)) {
-            if (Cache.passwordCacheForDecrypt != null) {
+            char[] pwd = Cache.passwordCacheForDecrypt.get(projectPath);
+            if (pwd != null) {
                 // 从缓存读取
-                return Cache.passwordCacheForDecrypt;
+                return pwd;
             }
             // 读取文件
             byte[] passwordByte = IOUtil.readFileFromWorkbenchRoot(new File(projectPath), Constant.PWD_WINTER);
@@ -345,8 +346,8 @@ public class DecryptExecutor {
             String password = new String(passwordByte, StandardCharsets.UTF_8);
             char[] passwordCharArr = password.toCharArray();
             // 放入缓存
-            Cache.passwordCacheForDecrypt = passwordCharArr;
-            return passwordCharArr;
+            Cache.passwordCacheForDecrypt.put(projectPath, passwordCharArr);
+            return Cache.passwordCacheForDecrypt.get(projectPath);
         } else {
             // lib包
             if (Cache.libPasswordCache != null && Cache.libPasswordCache.containsKey(classWinterInfoDir)) {

+ 8 - 2
class-winter-core/src/main/java/winter/com/ideaaedi/classwinter/util/Cache.java

@@ -14,8 +14,14 @@ import java.util.concurrent.ConcurrentHashMap;
  */
 public final class Cache {
     
-    /** 解密时的密码缓存 */
-    public static char[] passwordCacheForDecrypt = null;
+    /**
+     * 解密时的密码缓存
+     * <ul>
+     *     <li>key-projectPath</li>
+     *     <li>value-密码</li>
+     * </ul>
+     */
+    public static Map<String, char[]> passwordCacheForDecrypt = new ConcurrentHashMap<>(8);
     
     /**
      * 加密时的密码缓存