From 940439397559a91d9279cd72198597bb09145944 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 28 Mar 2023 15:27:08 +0200 Subject: [PATCH] db. Updated code --- src/var/lib/tyto/program/db.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/var/lib/tyto/program/db.py b/src/var/lib/tyto/program/db.py index deec7f3..2408988 100644 --- a/src/var/lib/tyto/program/db.py +++ b/src/var/lib/tyto/program/db.py @@ -26,8 +26,9 @@ remove = exists = post = corrupt = False try: in_dir = os.getcwd() except: logs.out("13", '', True) -in_dir = os.getcwd() - +# target needs db (file). +# action like show, wip, edit-db +# not domain, all, again... if args.target \ and args.action in args.pass_db \ and not args.target in args.pass_targets: @@ -38,7 +39,7 @@ if args.target \ uri_file = '%s/%s'%(in_dir, args.target) uri_id = tyto.get_filesum(uri_file, False) - # DB + # Set DB file config = '%s%s.config'%(dom.articles_db_d, uri_id) if tyto.exists(config): exists = True @@ -46,7 +47,7 @@ if args.target \ else: exists = False - # Article + # Article file exists if tyto.exists(uri_file): post = True hash_post = tyto.get_filesum(uri_file, True) @@ -55,9 +56,8 @@ if args.target \ remove = True logs.out("1", uri_file, False) - # Remove DB if unused source article or corrupted DB + # Check if database config is valid (contains values) if exists: - # Check if database config is valid (contains values) values = \ ( 'post_id', @@ -107,6 +107,7 @@ if args.target \ 'stat_quotes', 'stat_lists' ) + for value in values: try: eval(str(value)) @@ -114,7 +115,8 @@ if args.target \ remove = True corrupt = True break - + + # Remove DB if unused source article or corrupted DB if remove and exists: os.remove(config) exists = False @@ -145,4 +147,5 @@ if args.target \ if not hash_wip: no_wip = True if not hash_www: no_www = True + # Article is updated on both servers if hash_chk == hash_wip == hash_www: sync_srvs = True