From a94653302d47a65cbd72cde4bdadf011dea09cfa Mon Sep 17 00:00:00 2001 From: mananapr Date: Tue, 23 Jul 2019 21:59:10 +0530 Subject: [PATCH] Fixed buggy behaviour when files are misplaced --- akari/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/akari/utils.py b/akari/utils.py index 62fd458..592c758 100644 --- a/akari/utils.py +++ b/akari/utils.py @@ -23,6 +23,10 @@ def update_tags(tags, db): else: db['akari-tags'][tag] = 1 +def commit_changes(db): + with open(data_dir+'/db.json', 'w') as outfile: + json.dump(db, outfile) + def parse_result(result): soup = BeautifulSoup(result.text, 'html.parser') try: @@ -68,8 +72,7 @@ def scan_diretory(dirname, db): tags = parse_result(result) db[image] = tags update_tags(tags, db) - with open(data_dir+'/db.json', 'w') as outfile: - json.dump(db, outfile) + commit_changes(db) print(tags) print("-----x--x-----") @@ -103,6 +106,8 @@ def loadDB(): db['akari-tags'].pop(tag, None) print('{} tag removed'.format(tag)) + commit_changes(db) + return db def handle_flags():