Skip to content

Commit

Permalink
Fixed file selection from index
Browse files Browse the repository at this point in the history
  • Loading branch information
StrahinjaJacimovic committed Oct 14, 2024
1 parent 93af967 commit 9635797
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions scripts/check_indexes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, argparse, requests
import sys, json, argparse, requests

import classes.class_gh as gh
import classes.class_es as es
Expand Down Expand Up @@ -29,23 +29,15 @@
'Authorization': f'token {args.gh_token}'
}

strict_fetch = ['images']
fetch_fix = ['images_sdk']

err = False
for indexed_item in es_instance.indexed_items:
asset_status = requests.get(indexed_item['source']['download_link'], headers=headers)
if es_instance.Status.ERROR.value == asset_status.status_code: ## code 404 - error, reindex with correct download link
err = True
print("%sERROR: Asset \"%s\" download link is incorrect. - %s" % (es_instance.Colors.FAIL, indexed_item['source']['name'], indexed_item['source']['download_link']))
if not args.log_only:
loose = True
if indexed_item['source']['name'] in strict_fetch:
loose = False
check_package = indexed_item['source']['name']
if indexed_item['source']['name'] in fetch_fix:
check_package = indexed_item['source']['name'][:-4]
url = gh_instance.asset_fetch_url_api(check_package, loose=loose)
package_name = (json.loads(asset_status.text))['name']
url = gh_instance.asset_fetch_url_api(package_name, loose=False)
indexed_item['source']['download_link'] = url
es_instance.update(indexed_item['doc']['type'], indexed_item['doc']['id'], indexed_item['source'])
else: ## code 200 - success, no need to reindex
Expand Down

0 comments on commit 9635797

Please sign in to comment.