Compare commits

...

2 Commits

Author SHA1 Message Date
Jan Beníček e8f7f7ebf6 fix 2024-06-25 06:21:25 +02:00
Jan Beníček 5015a556da Fixing script crashing for no connection for download backup 2024-06-25 06:17:10 +02:00
2 changed files with 22 additions and 14 deletions

View File

@ -1,7 +1,8 @@
from conf import get_config
import pterodactylReader, fileDownloader, datetime, discordPoster, time, oldRemover
def run(run_number: int):
try:
conf = get_config()
api_client = pterodactylReader.init_client(config=conf)
today_date = datetime.datetime.now()
@ -17,3 +18,12 @@ if conf.discord_enabled == 1:
if conf.backups_keep_days != 0:
oldRemover.remove_old_files(today_date=today_date, keep_days=conf.backups_keep_days, root_path=conf.save_dir)
except Exception as e:
print(f"Error on try #{run_number}: {e}")
if run_number < 5:
run(run_number=(run_number + 1))
run(0)

View File

@ -17,8 +17,6 @@ def remove_old_files(today_date: datetime.datetime, keep_days: int, root_path: s
older_date = today_date - datetime.timedelta(days=keep_days)
last_date = today_date - datetime.timedelta(days=keep_days)
print(f"Candidate File: {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)