1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-21 23:27:29 +00:00

Fix temporary file removal

This commit is contained in:
Cadence Ember 2021-03-28 23:58:54 +13:00
parent 7ed3248104
commit 0f877b06bc
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -3,7 +3,9 @@ import os
def get_created_files(id):
if id[0] == "-":
id = "_" + id[1:] # youtube-dl changes - to _ at the start, presumably to not accidentally trigger switches with * in shell
return (f for f in os.listdir() if f.startswith("{}_".format(id)))
id += "_"
trim_id = id.lstrip("-_")
return (f for f in os.listdir() if f.startswith(id) or f.startswith(trim_id))
def clean_up_temp_files(id):
created_files = get_created_files(id)