# Source: https://github.com/RayWangQvQ/BiliBiliToolPro/blob/main/qinglong/DefaultTasks/bili_task_tryFix.sh
# Raw: https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/main/qinglong/DefaultTasks/bili_task_tryFix.sh
# Repo: RayWangQvQ/BiliBiliToolPro
# Path: qinglong/DefaultTasks/bili_task_tryFix.sh
# UploadedAt: 2025-09-22T22:41:56+08:00
# SHA256: 0b2693535ff68a9a83fd2e3586d4a961c4ed94c3530d9b0157dc45c783f12e06
# Category: 未分类
# Evidence: 规则未命中

#!/usr/bin/env bash
# cron:0 0 1 1 *
# new Env("bili尝试修复异常")

dir_shell=$QL_DIR/shell
. $dir_shell/share.sh
. /root/.bashrc

bili_repo="raywangqvq_bilibilitoolpro"
bili_branch=""

echo "青龙repo目录: $dir_repo"
qinglong_bili_repo="$(echo "$bili_repo" | sed 's/\//_/g')${bili_branch}"
qinglong_bili_repo_dir="$(find $dir_repo -type d \( -iname $qinglong_bili_repo -o -iname ${qinglong_bili_repo}_main \) | head -1)"
echo "bili仓库目录: $qinglong_bili_repo_dir"

echo -e "清理缓存...\n"
cd $qinglong_bili_repo_dir
find . -type d -name "bin" -exec rm -rf {} +
find . -type d -name "obj" -exec rm -rf {} +
echo -e "清理完成\n"

echo "检测dotnet..."
dotnetVersion=$(dotnet --version)
echo "当前dotnet版本：$dotnetVersion"
if [[ $(echo "$dotnetVersion" | grep -oE '^[0-9]+') -ge 8 ]]; then
    echo "已安装，且版本满足"
else
    echo "which dotnet: $(which dotnet)"
    echo "Path: $PATH"
    rm -f /usr/local/bin/dotnet
fi
echo "检测dotnet结束"