fix autoremover #5

main
Jan Beníček 2024-06-21 07:12:09 +02:00
parent 055a734096
commit 2ca0009427
1 changed files with 3 additions and 0 deletions

View File

@ -23,12 +23,15 @@ def remove_old_files(today_date: datetime.datetime, keep_days: int, root_path: s
print(older_date)
if last_date.year > older_date.year and Path(folder_path_year_creator(date=older_date, default_path=root_path)).exists():
shutil.rmtree(folder_path_year_creator(date=older_date, default_path=root_path))
print("year remover")
return
elif last_date.month > older_date.month and Path(folder_path_month_creator(date=older_date, default_path=root_path)).exists():
shutil.rmtree(folder_path_month_creator(date=older_date, default_path=root_path))
print("month remover")
return
elif os.path.exists(file_path_creator(date=older_date, default_path=root_path)):
os.remove(file_path_creator(date=older_date, default_path=root_path))
print("file remover")
last_date = datetime.datetime(year=older_date.year, month=older_date.month, day=older_date.day)