Skip to content

Commit f6bcdcc

Browse files
committed
Try 3 caches when using HTTP as well
1 parent f47ee67 commit f6bcdcc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

stashcp/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,10 @@ def download_http(source, destination, debug, payload):
404404
success = False
405405
start = end = 0
406406
tried_cache = ""
407-
for cache in nearest_cache_list[:2]:
407+
tries = 0
408+
# Try the 3 nearest caches
409+
for cache in nearest_cache_list[:min(3, len(nearest_cache_list)]:
410+
tries = tries + 1
408411
tried_cache = cache
409412
# Parse the nearest_cache url, make sure it uses http
410413
# Should really use urlparse, but python3 and python2 urlparse imports are
@@ -447,7 +450,7 @@ def download_http(source, destination, debug, payload):
447450
payload['filesize'] = filesize
448451

449452
payload['host']=tried_cache
450-
payload['tries']=1
453+
payload['tries']=tries
451454
payload['cache']=tried_cache
452455
if success:
453456
return True

0 commit comments

Comments
 (0)