fix autoremover #5
parent
055a734096
commit
2ca0009427
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue