Skip to content

Commit

Permalink
fix(22bc13d): Resolve speed concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninoScordino committed Sep 30, 2024
1 parent 6366499 commit 4a12838
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions extract_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ if [[ -f $URL ]]; then
else
MESSAGE="<code>Started</code> <a href=\"${URL}\">dump</a> <code>on</code> <a href=\"$BUILD_URL\">jenkins</a>
<b>Job ID:</b> <code>$BUILD_ID</code>."
<b>Dumper:</b>
if _json="$(sendTG normal "${MESSAGE}")"; then
# grab initial message id
MESSAGE_ID="$(jq ".result.message_id" <<< "${_json}")"
Expand All @@ -131,25 +132,25 @@ else

# If the device contains a link from Xiaomi's CDN, replace it (when applicable)
# with the fastest one
if [[ "${URL}" == *"d.miui.com"* ]] && [ ! "$(echo "${URL}" | grep -qE '(cdnorg|bkt-sgp-miui-ota-update-alisgp)')" ]; then
if [[ "${URL}" == *"d.miui.com"* ]] && [ ! "$(echo "${URL}" | grep -E '(cdnorg|bkt-sgp-miui-ota-update-alisgp)')" ]; then
# Set '${URL_ORIGINAL}' and '${FILE_PATH}' in case we might need to roll back
URL_ORIGINAL=${URL%/*}
URL_ORIGINAL=$(echo ${URL} | sed -E 's|(https://[^/]+).*|\1|')
FILE_PATH=${URL#*d.miui.com/}

# Array of different possible mirrors
MIRRORS=(
"https://cdnorg.d.miui.com"
"https://bkt-sgp-miui-ota-update-alisgp.oss-ap-southeast-1.aliyuncs.com"
"${URL_ORIGINAL}"
)

# Check back and forth for the best available mirror
for URLS in "${MIRRORS[@]}"; do
# Change mirror's domain with one(s) from array
URL=${URLS}/${FILE_PATH}

# Be sure that the mirror is available. Once it is, break the loop
if [ $(curl -s -o /dev/null -w "%{http_code}" "${URL}") == "404" ]; then
if [ "$(curl -I -sS "${URL}" | head -n1 | cut -d' ' -f2)" == "404" ]; then
echo "[ERROR] ${URLS} is not available. Trying with other mirror(s)..."
else
echo "[INFO] Found best available mirror."
Expand Down Expand Up @@ -717,7 +718,7 @@ brand=$(rg -m1 -INoP --no-messages "(?<=^ro.product.odm.brand=).*" odm/etc/${cod
[[ -z ${brand} ]] && brand=$(rg -m1 -INoP --no-messages "(?<=^ro.product.odm.brand=).*" vendor/odm/etc/build*.prop)
[[ -z ${brand} ]] && brand=$(rg -m1 -INoP --no-messages "(?<=^ro.product.brand=).*" {oppo_product,my_product}/build*.prop | head -1)
[[ -z ${brand} ]] && brand=$(echo "$fingerprint" | cut -d / -f1)
[[ -z ${brand} ]] && brand=$(echo "$brand")
[[ -z ${brand} ]] && brand=$(echo "$manufacturer")

description=$(rg -m1 -INoP --no-messages "(?<=^ro.build.description=).*" {system,system/system}/build.prop)
[[ -z ${description} ]] && description=$(rg -m1 -INoP --no-messages "(?<=^ro.build.description=).*" {system,system/system}/build*.prop)
Expand Down

0 comments on commit 4a12838

Please sign in to comment.