Skip to content

Commit b2339e2

Browse files
authored
feat(script): 更新流程优化 (#16)
在二进制安装更新流程中增加版本比较逻辑,如果版本一致则跳过更新流程,避免整体下载导致的流量浪费。
1 parent 844810a commit b2339e2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

script/v4.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,18 @@ UPDATE() {
835835
# 获取真实版本信息
836836
echo -e "${GREEN_COLOR}获取版本信息...${RES}"
837837
REAL_VERSION=$(curl -s "https://api.github.com/repos/OpenListTeam/OpenList/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' 2>/dev/null || echo "$VERSION_TAG")
838+
839+
# 检查当前版本
840+
CURRENT_VERSION=""
841+
if [ -f "$VERSION_FILE" ]; then
842+
CURRENT_VERSION=$(head -n1 "$VERSION_FILE" 2>/dev/null)
843+
fi
844+
845+
if [ -n "$CURRENT_VERSION" ] && [ "$CURRENT_VERSION" = "$REAL_VERSION" ]; then
846+
echo -e "${GREEN_COLOR}当前已是最新版本 ($CURRENT_VERSION),无需更新${RES}"
847+
return 0
848+
fi
849+
838850
GH_DOWNLOAD_URL="${GH_DOWNLOAD_URL}/${REAL_VERSION}"
839851

840852
# 停止 OpenList 服务

0 commit comments

Comments
 (0)