From 97799f1db2e6758c08e4614cfb4e738ef26bfe68 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 20 Aug 2019 11:10:33 +0100 Subject: [PATCH] Create actor cache when daemon starts --- cache.py | 4 ---- daemon.py | 6 ++++++ epicyon.py | 15 +++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cache.py b/cache.py index 75c852a3..182f14b1 100644 --- a/cache.py +++ b/cache.py @@ -22,10 +22,6 @@ def storePersonInCache(baseDir: str,personUrl: str,personJson: {},personCache: { return # store to file - if not os.path.isdir(baseDir+'/cache'): - os.mkdir(baseDir+'/cache') - if not os.path.isdir(baseDir+'/cache/actors'): - os.mkdir(baseDir+'/cache/actors') cacheFilename=baseDir+'/cache/actors/'+personUrl.replace('/','#')+'.json' if not os.path.isfile(cacheFilename): with open(cacheFilename, 'w') as fp: diff --git a/daemon.py b/daemon.py index c33bb393..05c0f9d0 100644 --- a/daemon.py +++ b/daemon.py @@ -2934,6 +2934,12 @@ def runDaemon(projectVersion, \ print('Creating shared inbox: inbox@'+domain) createSharedInbox(baseDir,'inbox',domain,port,httpPrefix) + if not os.path.isdir(baseDir+'/cache'): + os.mkdir(baseDir+'/cache') + if not os.path.isdir(baseDir+'/cache/actors'): + print('Creating actors cache') + os.mkdir(baseDir+'/cache/actors') + print('Creating inbox queue') httpd.thrInboxQueue= \ threadWithTrace(target=runInboxQueue, \ diff --git a/epicyon.py b/epicyon.py index 19f4afcc..b915bf7b 100644 --- a/epicyon.py +++ b/epicyon.py @@ -287,6 +287,11 @@ httpPrefix='https' if args.http: httpPrefix='http' +baseDir=args.baseDir +if baseDir.endswith('/'): + print("--path option should not end with '/'") + sys.exit() + if args.posts: if '@' not in args.posts: print('Syntax: --posts nickname@domain') @@ -313,10 +318,12 @@ if args.postsraw: __version__) sys.exit() -baseDir=args.baseDir -if baseDir.endswith('/'): - print("--path option should not end with '/'") - sys.exit() +# create cache for actors +if not os.path.isdir(baseDir+'/cache'): + os.mkdir(baseDir+'/cache') +if not os.path.isdir(baseDir+'/cache/actors'): + print('Creating actors cache') + os.mkdir(baseDir+'/cache/actors') if args.domain: domain=args.domain