Skip to content

Commit

Permalink
save result to local file if persist failed
Browse files Browse the repository at this point in the history
  • Loading branch information
wzdnzd committed Apr 15, 2024
1 parent 25af035 commit 9e10358
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions aggregate/subscribe/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ def aggregate(args: argparse.Namespace) -> None:
# compress if data is too large
compress = False if mixed else len(nochecks) >= 300

persisted, content = False, ""

if mixed or compress:
source_file = "config.yaml"
filepath = os.path.join(PATH, "subconverter", source_file)
Expand Down Expand Up @@ -545,7 +547,7 @@ def aggregate(args: argparse.Namespace) -> None:
continue

# save to remote server
pushtool.push_to(content=content, push_conf=push_conf, group=k)
persisted = pushtool.push_to(content=content, push_conf=push_conf, group=k)

# clean workspace
workflow.cleanup(
Expand All @@ -554,7 +556,13 @@ def aggregate(args: argparse.Namespace) -> None:
)
else:
content = yaml.dump(data=data, allow_unicode=True)
pushtool.push_to(content=content, push_conf=push_conf, group=k)
persisted = pushtool.push_to(content=content, push_conf=push_conf, group=k)

if content and not persisted:
filename = os.path.join(PATH, "data", f"{k}.txt")

logger.error(f"failed to push config to remote server, group: {k}, save it to {filename}")
utils.write_file(filename=filename, content=content)

config = {
"domains": sites,
Expand Down
2 changes: 1 addition & 1 deletion aggregate/subscribe/scripts/v2rayse.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def fetch(params: dict) -> list:

success = pushtool.push_to(content=content, push_conf=proxies_store, group="v2rayse")
if not success:
filename = os.path.join(datapath, "v2rayse.txt")
filename = os.path.join(os.path.dirname(datapath), "data", "v2rayse.txt")
logger.error(f"[V2RaySE] failed to storage {len(proxies)} proxies, will save it to local file {filename}")

utils.write_file(filename=filename, lines=content)
Expand Down

0 comments on commit 9e10358

Please sign in to comment.