Skip to content

Commit d9b9b81

Browse files
authored
Update run.sh
1 parent e91b2af commit d9b9b81

File tree

1 file changed

+12
-16
lines changed
  • scripts/transform_plugin_data/transform_plugin_data

1 file changed

+12
-16
lines changed

scripts/transform_plugin_data/transform_plugin_data/run.sh

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ cleanup_existing_cache="false"
99
# 如果没有历史缓存,为jq提供一个空对象以便统一逻辑
1010
if [ ! -f "$existing_cache_file" ]; then
1111
existing_cache_file=$(mktemp)
12-
echo "{}" > "$existing_cache_file"
12+
if [ -f "plugin_cache_original.json" ]; then
13+
cp plugin_cache_original.json "$existing_cache_file"
14+
else
15+
echo "{}" > "$existing_cache_file"
16+
fi
1317
cleanup_existing_cache="true"
1418
fi
1519

@@ -21,27 +25,17 @@ jq --slurpfile repo_info repo_info.json --slurpfile existing_cache "$existing_ca
2125
else {}
2226
end) as $cache |
2327
to_entries |
24-
# 只过滤掉确认已删除(404)的仓库,保留网络错误的仓库
25-
map(select(
26-
if .value.repo and ($repos[.value.repo]) then
27-
($repos[.value.repo].status != "deleted") and (
28-
if $repos[.value.repo].status == "success" then
29-
true
30-
else
31-
($cache | has(.key))
32-
end
33-
)
34-
else
35-
true
36-
end
37-
)) |
3828
map(
3929
. as $plugin |
4030
($repos[$plugin.value.repo] // null) as $repo_entry |
4131
($cache[$plugin.key] // {}) as $cache_entry |
32+
($repo_entry | if . then .status else "" end) as $repo_status |
33+
# 403 等非 success 且没有缓存的仓库直接丢弃,保持缓存一致性
34+
if ($repo_entry and ($repo_status == "deleted" or ($repo_status != "success" and ($cache_entry | length) == 0))) then
35+
empty
36+
else
4237
($repo_entry | if . then .version else "" end) as $repo_version |
4338
($cache_entry.version // "") as $cache_version |
44-
($repo_entry | if . then .status else "" end) as $repo_status |
4539
($repo_entry | if . then .stars else null end) as $repo_stars |
4640
($cache_entry.stars // 0) as $cache_stars |
4741
($repo_entry | if . then .updated_at else "" end) as $repo_updated |
@@ -81,6 +75,7 @@ map(
8175
+ (if ($final_logo // "") != "" then { logo: $final_logo } else {} end)
8276
)
8377
}
78+
end
8479
) | from_entries' original_plugins.json > temp_plugin_cache_original.json
8580

8681
if [ "$cleanup_existing_cache" = "true" ]; then
@@ -137,3 +132,4 @@ if [ "$redirected_repos" -gt 0 ]; then
137132
jq -r 'to_entries[] | select(.value.status == "redirected") | " - " + .key' repo_info.json
138133
fi
139134

135+

0 commit comments

Comments
 (0)