fix autoremover #6
parent
2ca0009427
commit
cd0fa8a446
|
@ -9,14 +9,14 @@ def folder_path_month_creator(date: datetime.datetime, default_path: str) -> str
|
|||
return f"{folder_path_year_creator(date=date, default_path=default_path)}/{date.month}"
|
||||
|
||||
def file_path_creator(date: datetime.datetime, default_path: str) -> str:
|
||||
return f"{folder_path_month_creator(date=date, default_path=default_path)}/{date.day}.tar.gz"
|
||||
return f"{folder_path_month_creator(date=date, default_path=default_path)}/{date.year}_{date.month}_{date.day}.tar.gz"
|
||||
|
||||
|
||||
def remove_old_files(today_date: datetime.datetime, keep_days: int, root_path: str):
|
||||
older_date = today_date - datetime.timedelta(days=keep_days)
|
||||
last_date = today_date - datetime.timedelta(days=keep_days)
|
||||
print(today_date)
|
||||
print(older_date)
|
||||
|
||||
print(file_path_creator(date=older_date, default_path=root_path))
|
||||
|
||||
while older_date > (datetime.datetime.now() - datetime.timedelta(days=10 + keep_days)):
|
||||
older_date = older_date - datetime.timedelta(days=1)
|
||||
|
@ -32,7 +32,6 @@ def remove_old_files(today_date: datetime.datetime, keep_days: int, root_path: s
|
|||
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