From b877af4ae8abe1c7c8abb67ce82d1edc561e1825 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 2 Nov 2019 11:32:43 +0000 Subject: [PATCH] Only write if file does not exist --- shares.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shares.py b/shares.py index 4e516735..5b567082 100644 --- a/shares.py +++ b/shares.py @@ -146,11 +146,12 @@ def addShare(baseDir: str, \ # indicate that a new share is available newShareFile=baseDir+'/accounts/.newShare' - try: - with open(newShareFile, 'w') as fp: - fp.write('\n') - except: - pass + if not os.path.isfile(newShareFile): + try: + with open(newShareFile, 'w') as fp: + fp.write('\n') + except: + pass def expireShares(baseDir: str) -> None: """Removes expired items from shares