Redirect + trackers + php upload api + binary tree search + uuids

This commit is contained in:
relikd
2020-08-29 14:44:01 +02:00
parent ec6e4b5a90
commit 1d731e709f
17 changed files with 16565 additions and 99 deletions

View File

@@ -1,23 +1,13 @@
#!/usr/bin/env python3
import os
import common_lib as mylib
import bundle_import
import bundle_combine
import bundle_download
import html_root
import html_index
import html_bundle
def reset_new():
print("RESET json files ...")
prefix = mylib.path_len(mylib.path_data())
for bid in mylib.enum_appids():
for src, _ in mylib.enum_jsons(bid):
frmt = mylib.path_add(mylib.path_data('_in', '%s.json'))
dest = bundle_import.next_path(frmt)
mylib.mv(src, dest, printOmitPrefix=prefix)
print('')
import tracker_download
def del_id(bundle_ids):
@@ -31,25 +21,51 @@ def del_id(bundle_ids):
html_index.process()
def full_chain(force=False):
bundle_ids = bundle_import.process()
if force:
bundle_ids = list(mylib.enum_data_appids())
if len(bundle_ids) > 0:
bundle_combine.process(bundle_ids)
new_ids = html_bundle.process(bundle_ids)
if len(new_ids) > 0:
bundle_download.process(new_ids)
html_index.process()
html_root.process()
def combine_and_update(bundle_ids, where=None, forceGraphs=False):
affected = bundle_combine.process(bundle_ids, where=where)
if len(affected) == 0:
print('no bundle affected by tracker, not generating bundle html')
return
new_ids = html_bundle.process(affected, forceGraphs=forceGraphs)
if len(new_ids) == 0:
print('no new bundle, not rebuilding index')
return
bundle_download.process(new_ids)
html_index.process()
html_root.process()
def import_update():
print('checking incoming data ...')
needs_update = set()
for fname, bid in mylib.enum_newly_added():
if bid == '_manually':
# TODO: notify admin that manual action is required
mylib.err('import', 'manual action required!')
else:
print('none to import, not rebuilding index')
print(' ' + bid)
needs_update.add(bid)
os.remove(fname)
print('')
if len(needs_update) > 0:
combine_and_update(needs_update, forceGraphs=True)
def tracker_update():
new_trackers = tracker_download.process()
if new_trackers:
combine_and_update(['*'], where=new_trackers)
def process():
# reset_new()
# del_id(['*'])
full_chain(force=False)
# del_id(['_manually'])
import_update()
# tracker_update()
# tracker_download.combine_all('x')
# combine_and_update(['*']) # where=['test.com']
# if bundle_download.download_missing_icons(force=False):
# html_index.process()
# html_index.process()
process()