Make deletion async friendly
This commit is contained in:
parent
b1de6737f0
commit
cfcf7e39f0
@ -27,12 +27,14 @@ use/prefer public interfaces ? (export functions)
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def try_deleting(files):
|
async def try_deleting(files):
|
||||||
for f in files:
|
for f in files:
|
||||||
try:
|
try:
|
||||||
os.remove(f)
|
path = trio.Path(f)
|
||||||
except OSError:
|
if os.path.exists(path):
|
||||||
pass
|
await path.rmdir()
|
||||||
|
except Exception as exception:
|
||||||
|
print("PANIC: {}".format(exception))
|
||||||
|
|
||||||
|
|
||||||
def build_argument_parser(args):
|
def build_argument_parser(args):
|
||||||
@ -307,7 +309,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
## ENFORCE __NOPUBLISH__ MAGIC WORD
|
## ENFORCE __NOPUBLISH__ MAGIC WORD
|
||||||
##########################################
|
##########################################
|
||||||
if args.nopublish in text:
|
if args.nopublish in text:
|
||||||
try_deleting(
|
await try_deleting(
|
||||||
(
|
(
|
||||||
p + raw_ext,
|
p + raw_ext,
|
||||||
p + ".raw.html",
|
p + ".raw.html",
|
||||||
@ -326,7 +328,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
## ENFORCE __PUBLISH__ MAGIC WORD
|
## ENFORCE __PUBLISH__ MAGIC WORD
|
||||||
##########################################
|
##########################################
|
||||||
if args.publish_opt_in and args.publish not in text:
|
if args.publish_opt_in and args.publish not in text:
|
||||||
try_deleting(
|
await try_deleting(
|
||||||
(
|
(
|
||||||
p + raw_ext,
|
p + raw_ext,
|
||||||
p + ".raw.html",
|
p + ".raw.html",
|
||||||
|
Loading…
Reference in New Issue
Block a user