Refactor disable_auto_update() function in Linux script

- Improved error handling logic with more concise conditional checks
- Replaced complex multi-line command with an if statement for better readability
- Simplified file permission and ownership setting validation
- Maintained existing error logging and manual guide display functionality
This commit is contained in:
煎饼果子卷鲨鱼辣椒 2025-01-25 20:16:56 +08:00
parent 2cfd7e63e5
commit 708285a2ef

View File

@ -295,12 +295,11 @@ disable_auto_update() {
return 1 return 1
} }
chmod 444 "$updater_path" 2>/dev/null && \ if ! chmod 444 "$updater_path" 2>/dev/null || ! chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null; then
chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null || {
log_error "设置文件权限失败" log_error "设置文件权限失败"
show_manual_guide show_manual_guide
return 1 return 1
} fi
# 尝试设置不可修改属性 # 尝试设置不可修改属性
if command -v chattr &> /dev/null; then if command -v chattr &> /dev/null; then
@ -316,7 +315,7 @@ disable_auto_update() {
log_error "验证失败:文件权限设置可能未生效" log_error "验证失败:文件权限设置可能未生效"
show_manual_guide show_manual_guide
return 1 return 1
} fi
log_info "成功禁用自动更新" log_info "成功禁用自动更新"
else else