修复 getpats4mv 函数中的 checksum 获取逻辑,确保在缺失时返回默认值 '0' * 32

This commit is contained in:
Ing 2025-05-12 21:46:04 +08:00
parent 2ff44c4b1f
commit 2a4eb4996d
3 changed files with 294 additions and 294 deletions

View File

@ -234,7 +234,7 @@ def getpats4mv(model, version):
if V not in pats: if V not in pats:
pats[V] = { pats[V] = {
'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0], 'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': data['info']['system']['detail'][0]['items'][0]['files'][0]['checksum'] 'sum': data['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
} }
from_ver = min(I['build'] for I in data['info']['pubVers']) from_ver = min(I['build'] for I in data['info']['pubVers'])
@ -256,7 +256,7 @@ def getpats4mv(model, version):
if V not in pats: if V not in pats:
pats[V] = { pats[V] = {
'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0], 'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['checksum'] 'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
} }
for J in I['versions']: for J in I['versions']:
@ -276,7 +276,7 @@ def getpats4mv(model, version):
continue continue
pats[V] = { pats[V] = {
'url': S['files'][0]['url'].split('?')[0], 'url': S['files'][0]['url'].split('?')[0],
'sum': S['files'][0]['checksum'] 'sum': S['files'][0].get('checksum', '0' * 32)
} }
except Exception as e: except Exception as e:
# click.echo(f"Error: {e}") # click.echo(f"Error: {e}")

View File

@ -1401,7 +1401,7 @@ function extractDsmFiles() {
fi fi
printf "$(TEXT "Checking hash of %s:")" "${PAT_FILE}" printf "$(TEXT "Checking hash of %s:")" "${PAT_FILE}"
if [ "$(md5sum "${PAT_PATH}" | awk '{print $1}')" != "${PATSUM}" ]; then if [ "00000000000000000000000000000000" != "${PATSUM}" ] && [ "$(md5sum "${PAT_PATH}" | awk '{print $1}')" != "${PATSUM}" ]; then
rm -f "${PAT_PATH}" rm -f "${PAT_PATH}"
echo -e "$(TEXT "md5 hash of pat not match, Please reget pat data from the version menu and try again!")" >"${LOG_FILE}" echo -e "$(TEXT "md5 hash of pat not match, Please reget pat data from the version menu and try again!")" >"${LOG_FILE}"
return 1 return 1

View File

@ -151,7 +151,7 @@ def getpats(workpath, jsonpath, xlsxpath):
if V not in pats[M]: if V not in pats[M]:
pats[M][V] = { pats[M][V] = {
'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0], 'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': data['info']['system']['detail'][0]['items'][0]['files'][0]['checksum'] 'sum': data['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
} }
from_ver = min(I['build'] for I in data['info']['pubVers']) from_ver = min(I['build'] for I in data['info']['pubVers'])
@ -177,7 +177,7 @@ def getpats(workpath, jsonpath, xlsxpath):
if V not in pats[M]: if V not in pats[M]:
pats[M][V] = { pats[M][V] = {
'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0], 'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['checksum'] 'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
} }
for J in I['versions']: for J in I['versions']:
@ -202,7 +202,7 @@ def getpats(workpath, jsonpath, xlsxpath):
continue continue
pats[M][V] = { pats[M][V] = {
'url': S['files'][0]['url'].split('?')[0], 'url': S['files'][0]['url'].split('?')[0],
'sum': S['files'][0]['checksum'] 'sum': S['files'][0].get('checksum', '0' * 32)
} }
if jsonpath: if jsonpath: