From a318f299ca6c8f7a07b6aedb671053d0395b6fe1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 20 Oct 2019 11:45:12 +0100 Subject: [PATCH] Write first entry in index --- inbox.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/inbox.py b/inbox.py index 4b7311645..3b69bfa06 100644 --- a/inbox.py +++ b/inbox.py @@ -1512,11 +1512,18 @@ def inboxUpdateIndex(baseDir: str,handle: str,destinationFilename: str,debug: bo indexFilename=baseDir+'/accounts/'+handle+'/inbox.index' if debug: print('DEBUG: Updating index '+indexFilename) - with open(indexFilename, 'r+') as indexFile: - content = indexFile.read() - indexFile.seek(0, 0) - indexFile.write(destinationFilename+'\n'+content) - return True + if os.path.isfile(indexFilename): + with open(indexFilename, 'r+') as indexFile: + content = indexFile.read() + indexFile.seek(0, 0) + indexFile.write(destinationFilename+'\n'+content) + return True + else: + indexFile=open(indexFilename,'w+') + if indexFile: + indexFile.write(destinationFilename+'\n') + indexFile.close() + return False def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \