From eac1ffe99380c3be728f23a74fbce837bb87b73b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 20 Aug 2019 22:26:24 +0100 Subject: [PATCH] Check for presence of cache directory --- cache.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cache.py b/cache.py index 835ce4eb..110f4add 100644 --- a/cache.py +++ b/cache.py @@ -23,10 +23,11 @@ def storePersonInCache(baseDir: str,personUrl: str,personJson: {},personCache: { return # store to file - cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json' - if not os.path.isfile(cacheFilename): - with open(cacheFilename, 'w') as fp: - commentjson.dump(personJson, fp, indent=4, sort_keys=False) + if os.path.isdir(baseDir+'/cache/actors'): + cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json' + if not os.path.isfile(cacheFilename): + with open(cacheFilename, 'w') as fp: + commentjson.dump(personJson, fp, indent=4, sort_keys=False) def getPersonFromCache(baseDir: str,personUrl: str,personCache: {}) -> {}: """Get an actor from the cache