Skip to content

Commit 9635797

Browse files
Fixed file selection from index
1 parent 93af967 commit 9635797

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

scripts/check_indexes.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys, argparse, requests
1+
import sys, json, argparse, requests
22

33
import classes.class_gh as gh
44
import classes.class_es as es
@@ -29,23 +29,15 @@
2929
'Authorization': f'token {args.gh_token}'
3030
}
3131

32-
strict_fetch = ['images']
33-
fetch_fix = ['images_sdk']
34-
3532
err = False
3633
for indexed_item in es_instance.indexed_items:
3734
asset_status = requests.get(indexed_item['source']['download_link'], headers=headers)
3835
if es_instance.Status.ERROR.value == asset_status.status_code: ## code 404 - error, reindex with correct download link
3936
err = True
4037
print("%sERROR: Asset \"%s\" download link is incorrect. - %s" % (es_instance.Colors.FAIL, indexed_item['source']['name'], indexed_item['source']['download_link']))
4138
if not args.log_only:
42-
loose = True
43-
if indexed_item['source']['name'] in strict_fetch:
44-
loose = False
45-
check_package = indexed_item['source']['name']
46-
if indexed_item['source']['name'] in fetch_fix:
47-
check_package = indexed_item['source']['name'][:-4]
48-
url = gh_instance.asset_fetch_url_api(check_package, loose=loose)
39+
package_name = (json.loads(asset_status.text))['name']
40+
url = gh_instance.asset_fetch_url_api(package_name, loose=False)
4941
indexed_item['source']['download_link'] = url
5042
es_instance.update(indexed_item['doc']['type'], indexed_item['doc']['id'], indexed_item['source'])
5143
else: ## code 200 - success, no need to reindex

0 commit comments

Comments
 (0)