用户反馈:马斯克从 people.json 删了但仍被拦(黑名单拦截[关键词:马斯克])。 根因:loadConfig 每次 blacklist.clear() 后目录扫描,people.json 指纹命中(文件没变) 时无条件从 blacklistFileKeywords 恢复缓存词(含被删的马斯克)→ 幽灵词残留。 删词后若缓存滞后/文件 I/O 延迟,被删词仍被回补进 blacklist。 修复(AIChatManager.java L341 指纹命中分支): 回补前用「当前文件解析词」校验缓存词,只回补「缓存词 ∩ 当前文件词」—— 被删的词(不在当前文件里)不回补,删词立即生效。 需重启清空内存 blacklist/blacklistFileKeywords 残留后生效。
This commit is contained in:
@@ -344,9 +344,25 @@ public class AIChatManager {
|
|||||||
// 未变化文件的词被永久丢光 → 黑名单只剩配置内联词。
|
// 未变化文件的词被永久丢光 → 黑名单只剩配置内联词。
|
||||||
// 生产日志铁证:启动 129 条(127目录+2配置)→ 后续每请求仅 2 条。
|
// 生产日志铁证:启动 129 条(127目录+2配置)→ 后续每请求仅 2 条。
|
||||||
// 修复:指纹命中时从 blacklistFileKeywords 恢复旧词。
|
// 修复:指纹命中时从 blacklistFileKeywords 恢复旧词。
|
||||||
|
// ★ 第121批续25:删词立即生效——指纹命中回补前,用「当前文件解析词」
|
||||||
|
// 校验缓存词,被删的词(不在当前文件里)不回补。
|
||||||
|
// 旧逻辑无条件回补缓存词 → 用户删词后若文件指纹因编辑器换行/空格
|
||||||
|
// 未变(或缓存滞后),被删词仍被回补进 blacklist → 幽灵词拦截。
|
||||||
List<String> existing = blacklistFileKeywords.get(fileName);
|
List<String> existing = blacklistFileKeywords.get(fileName);
|
||||||
if (existing != null && !existing.isEmpty()) {
|
if (existing != null && !existing.isEmpty()) {
|
||||||
blacklist.addAll(existing);
|
List<String> currentFileWords = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
JsonArray arr = JsonParser.parseString(jsonContent).getAsJsonArray();
|
||||||
|
for (JsonElement el : arr) {
|
||||||
|
if (el.isJsonPrimitive()) currentFileWords.add(el.getAsString());
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
// 回补「缓存词 ∩ 当前文件词」——被删的词不回补
|
||||||
|
for (String w : existing) {
|
||||||
|
if (currentFileWords.contains(w)) {
|
||||||
|
blacklist.add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user