From cfcf7e39f06759810208ea4960efba276864cef0 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 3 Oct 2020 13:23:09 +0200 Subject: [PATCH] Make deletion async friendly --- etherpump/commands/pull.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/etherpump/commands/pull.py b/etherpump/commands/pull.py index 26e7c55..a8044bf 100644 --- a/etherpump/commands/pull.py +++ b/etherpump/commands/pull.py @@ -27,12 +27,14 @@ use/prefer public interfaces ? (export functions) """ -def try_deleting(files): +async def try_deleting(files): for f in files: try: - os.remove(f) - except OSError: - pass + path = trio.Path(f) + if os.path.exists(path): + await path.rmdir() + except Exception as exception: + print("PANIC: {}".format(exception)) def build_argument_parser(args): @@ -307,7 +309,7 @@ async def handle_pad(args, padid, data, info, session): ## ENFORCE __NOPUBLISH__ MAGIC WORD ########################################## if args.nopublish in text: - try_deleting( + await try_deleting( ( p + raw_ext, p + ".raw.html", @@ -326,7 +328,7 @@ async def handle_pad(args, padid, data, info, session): ## ENFORCE __PUBLISH__ MAGIC WORD ########################################## if args.publish_opt_in and args.publish not in text: - try_deleting( + await try_deleting( ( p + raw_ext, p + ".raw.html",