Browse Source

luci-app-ssr-plus: Fix subscribe code.

zxl hhyccc 1 week ago
parent
commit
6d0f2768b1
1 changed files with 9 additions and 24 deletions
  1. 9 24
      luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua

+ 9 - 24
luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua

@@ -1187,36 +1187,21 @@ local execute = function()
 										log('丢弃无效节点: ' .. result.alias)
 									else
 										-- log('成功解析: ' .. result.type ..' 节点, ' .. result.alias)
-										-- 统一标记 grouphashkey
-										result.grouphashkey = groupHash
-										-- 初始化缓存
-										cache[groupHash] = cache[groupHash] or {}
-										-- 初始化 hashkey 对应的节点数组
+										-- 检查重复(hashkey + alias)节点
 										cache[groupHash][result.hashkey] = cache[groupHash][result.hashkey] or {}
-
-										-- 初始化 nodeResult[index]
-										nodeResult[index] = nodeResult[index] or {}
-
-										-- 检查是否有完全重复(hashkey + alias)节点
-										local is_duplicate = nil
-										for i, r in ipairs(cache[groupHash][result.hashkey]) do
+										local is_duplicate = false
+										for _, r in ipairs(cache[groupHash][result.hashkey]) do
 											if r.alias == result.alias then
-									       		is_duplicate = i
+									       		is_duplicate = true
 										   		break
 											end
 										end
-
-										if is_duplicate then
-											-- 已经存在完全重复节点,直接丢弃其他重复节点
-											log('丢弃重复节点: ' .. result.alias)
-											return
+										if not is_duplicate then
+											result.grouphashkey = groupHash
+											tinsert(nodeResult[index], result)
+											cache[groupHash][result.hashkey] = nodeResult[index][#nodeResult[index]]
 										else
-											-- **直接覆盖缓存中同 hashkey 的节点**
-											cache[groupHash][result.hashkey] = {result} 
-											-- 将节点加入 nodeResult
-											table.insert(nodeResult[index], result)
-											-- 更新 hashkey 对应的节点数量
-											cache_count[groupHash][result.hashkey] = #cache[groupHash][result.hashkey]
+											log('丢弃重复节点: ' .. result.alias)
 										end
 									end
 								end