Skip to content

Commit 577cbe4

Browse files
Merge branch 'master' into wip/filesize
2 parents cf653df + 59645a3 commit 577cbe4

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

bin/stashcp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,19 @@ def get_ips(name):
377377
return ipv4s + ipv6s
378378

379379
def get_best_stashcache():
380-
381-
# First, check for caches.json file in this file's directory:
382-
dir_path = os.path.dirname(os.path.realpath(__file__))
383-
cache_file = os.path.join(dir_path, 'caches.json')
384-
if not os.path.isfile(cache_file):
385-
logging.error("Unable to find caches.json in %s", dir_path)
380+
cache_files = [os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
381+
"/etc/stashcache/caches.json",
382+
"/usr/share/stashcache/caches.json"]
383+
for cache_file in cache_files:
384+
if os.path.isfile(cache_file):
385+
with open(cache_file, 'r') as f:
386+
caches_list = json.loads(f.read())
387+
logging.debug("Loaded caches list from %s", cache_file)
388+
break
389+
else:
390+
logging.error("Unable to find caches.json in %r", cache_files)
386391
return None
387-
388-
# Get all the caches from the json file
389-
f = open(cache_file, 'r')
390-
caches_list = json.loads(f.read())
391-
f.close()
392-
392+
393393
# Format the caches for the GeoIP query
394394
caches_string = ""
395395
usable_caches = []

0 commit comments

Comments
 (0)