From 1a920e4e2614bba644f92dd850b638237ec2c08c Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Thu, 5 Dec 2024 01:37:31 -0600 Subject: [PATCH] Various fixes for common --- common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common.py b/common.py index 92c78aa..099b2a6 100755 --- a/common.py +++ b/common.py @@ -16,13 +16,13 @@ # along with this program. If not, see . import os -from datetime import datetime +from datetime import datetime, timezone def clean_old_logs(log_dir, max_age_seconds=86400): - now = datetime.utcnow() + now = datetime.now(timezone.utc) for file_name in os.listdir(log_dir): file_path = os.path.join(log_dir, file_name) if os.path.isfile(file_path): - file_age = now - os.path.getmtime(file_path) - if file_age > max_age_seconds: + file_age = now - datetime.fromtimestamp(os.path.getmtime(file_path), tz=timezone.utc) + if file_age > timedelta(seconds=max_age_seconds): os.remove(file_path)