Fix the cleanup

pull/1296/head
Simon 2 years ago
parent 85d0f33651
commit 6a155334f0

@ -12,18 +12,18 @@ def cleanup(id) -> int:
Returns: Returns:
int: How many files were deleted int: How many files were deleted
""" """
if exists("./assets/temp"): if exists(f"../assets/temp/{id}/"):
count = 0 count = 0
files = [f for f in os.listdir(".") if f.endswith(".mp4") and "temp" in f.lower()] files = [f for f in os.listdir(f"../assets/temp/{id}/") if f.endswith(".mp4")]
count += len(files) count += len(files)
for f in files: for f in files:
os.remove(f) os.remove(f"../assets/temp/{id}/{f}")
REMOVE_DIRS = [f"./assets/temp/{id}/mp3/", f"./assets/temp/{id}/png/"] REMOVE_DIRS = [f"../assets/temp/{id}/mp3/", f"../assets/temp/{id}/png/"]
files_to_remove = list(map(_listdir, REMOVE_DIRS)) for d in REMOVE_DIRS:
for directory in files_to_remove: if exists(d):
for file in directory: count += len(_listdir(d))
count += 1 for f in _listdir(d):
os.remove(file) os.remove(f)
os.rmdir(d)
os.rmdir(f"../assets/temp/{id}/")
return count return count
return 0

Loading…
Cancel
Save