Don't raise if there is no matching entry

parent 86264fb8
......@@ -198,20 +198,19 @@ def helper_download_network_cached(dir_url, cache_url,
matching_entry_list.append(tags)
except Exception:
pass
if matching_entry_list:
# If a strategy is defined, call it to determine best entry
if strategy:
best_entry = strategy(matching_entry_list)
if not best_entry:
logger.info("Can't find best entry matching strategy, selecting "
"random one between acceptable ones.")
if strategy:
best_entry = strategy(matching_entry_list)
if not best_entry:
logger.info("Can't find best entry matching strategy, selecting "
"random one between acceptable ones.")
best_entry = matching_entry_list[0]
else:
best_entry = matching_entry_list[0]
else:
best_entry = matching_entry_list[0]
# download best entry
file_descriptor = nc.download(best_entry.get('sha512'))
if file_descriptor is not None:
# download best entry
file_descriptor = nc.download(best_entry.get('sha512'))
return file_descriptor, tags
else:
logger.info('No matching entry to download from network cache: %s'\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment