File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -374,19 +374,19 @@ def get_ips(name):
374374 return ipv4s + ipv6s
375375
376376def get_best_stashcache ():
377-
378- # First, check for caches.json file in this file's directory:
379- dir_path = os .path .dirname (os .path .realpath (__file__ ))
380- cache_file = os .path .join (dir_path , 'caches.json' )
381- if not os .path .isfile (cache_file ):
382- logging .error ("Unable to find caches.json in %s" , dir_path )
377+ cache_files = [os .path .join (os .path .dirname (os .path .realpath (__file__ )), "caches.json" ),
378+ "/etc/stashcache/caches.json" ,
379+ "/usr/share/stashcache/caches.json" ]
380+ for cache_file in cache_files :
381+ if os .path .isfile (cache_file ):
382+ with open (cache_file , 'r' ) as f :
383+ caches_list = json .loads (f .read ())
384+ logging .debug ("Loaded caches list from %s" , cache_file )
385+ break
386+ else :
387+ logging .error ("Unable to find caches.json in %r" , cache_files )
383388 return None
384-
385- # Get all the caches from the json file
386- f = open (cache_file , 'r' )
387- caches_list = json .loads (f .read ())
388- f .close ()
389-
389+
390390 # Format the caches for the GeoIP query
391391 caches_string = ""
392392 usable_caches = []
You can’t perform that action at this time.
0 commit comments