Don't raise if there is no matching entry

parent 86264fb8
...@@ -198,20 +198,19 @@ def helper_download_network_cached(dir_url, cache_url, ...@@ -198,20 +198,19 @@ def helper_download_network_cached(dir_url, cache_url,
matching_entry_list.append(tags) matching_entry_list.append(tags)
except Exception: except Exception:
pass pass
if matching_entry_list:
# If a strategy is defined, call it to determine best entry # If a strategy is defined, call it to determine best entry
if strategy: if strategy:
best_entry = strategy(matching_entry_list) best_entry = strategy(matching_entry_list)
if not best_entry: if not best_entry:
logger.info("Can't find best entry matching strategy, selecting " logger.info("Can't find best entry matching strategy, selecting "
"random one between acceptable ones.") "random one between acceptable ones.")
best_entry = matching_entry_list[0]
else:
best_entry = matching_entry_list[0] 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 return file_descriptor, tags
else: else:
logger.info('No matching entry to download from network cache: %s'\ 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