Updated cdx file retention to 2 days

This commit is contained in:
datechnoman 2024-01-09 21:15:18 +00:00
parent 1e44917569
commit 6c16ee45bd

View File

@ -179,12 +179,12 @@ def main():
directory_output_file.write(f"{filename}\n")
# Process older files in /opt/cdxfiles/imgur
older_than_24_hours = datetime.now() - timedelta(days=1)
older_than_48_hours = datetime.now() - timedelta(days=2)
for filename in os.listdir(IMGUR_DIRECTORY):
file_path = os.path.join(IMGUR_DIRECTORY, filename)
if filename.endswith(".cdx.json") and os.path.getmtime(file_path) < older_than_24_hours.timestamp():
if filename.endswith(".cdx.json") and os.path.getmtime(file_path) < older_than_48_hours.timestamp():
os.remove(file_path)
print(f"Deleted '{filename}' as it is older than 24 hours.")
print(f"Deleted '{filename}' as it is older than 48 hours.")
run_ia_command() # Run IA command after processing older files