From b832338f0e2a0615a11005a7b7b948bffb7961d2 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Pasquier <contact@jbpasquier.eu>
Date: Fri, 21 Jun 2024 19:00:54 +0200
Subject: [PATCH] feature: remove file older than 24h

---
 djangoldp/views.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/djangoldp/views.py b/djangoldp/views.py
index f4453e4..0325411 100644
--- a/djangoldp/views.py
+++ b/djangoldp/views.py
@@ -1,6 +1,7 @@
 import json
 import logging
 import os
+import time
 
 import validators
 from django.apps import apps
@@ -633,6 +634,13 @@ def serve_static_content(request, path):
     if not file_path.endswith('.jsonld'):
         file_path += '.jsonld'
 
+    if os.path.exists(file_path):
+        current_time = time.time()
+        file_mod_time = os.path.getmtime(file_path)
+        time_difference = current_time - file_mod_time
+        if time_difference > 24 * 60 * 60:
+            os.remove(file_path)
+
     if not os.path.exists(file_path):
 
         resolver = get_resolver()
-- 
GitLab