db. Updated code

This commit is contained in:
Cyrille L 2023-03-28 15:27:08 +02:00
parent 2d13d4ea8a
commit 9404393975
1 changed files with 10 additions and 7 deletions

View File

@ -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
if exists:
# Check if database config is valid (contains values)
if exists:
values = \
(
'post_id',
@ -107,6 +107,7 @@ if args.target \
'stat_quotes',
'stat_lists'
)
for value in values:
try:
eval(str(value))
@ -115,6 +116,7 @@ if args.target \
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