Update utils/cache_manager.py
Browse files- utils/cache_manager.py +8 -1
utils/cache_manager.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from diskcache import Cache
|
| 2 |
from functools import wraps
|
| 3 |
import hashlib
|
|
@@ -6,7 +7,13 @@ import os
|
|
| 6 |
from config import settings
|
| 7 |
|
| 8 |
# Handle Spaces environment - use /tmp if available
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
if not os.path.exists(cache_dir):
|
| 11 |
os.makedirs(cache_dir, exist_ok=True)
|
| 12 |
|
|
|
|
| 1 |
+
# cache_manager.py
|
| 2 |
from diskcache import Cache
|
| 3 |
from functools import wraps
|
| 4 |
import hashlib
|
|
|
|
| 7 |
from config import settings
|
| 8 |
|
| 9 |
# Handle Spaces environment - use /tmp if available
|
| 10 |
+
def get_cache_dir():
|
| 11 |
+
"""Get cache directory that works on Spaces"""
|
| 12 |
+
if os.path.exists("/tmp"):
|
| 13 |
+
return "/tmp/.cache"
|
| 14 |
+
return settings.CACHE_DIR
|
| 15 |
+
|
| 16 |
+
cache_dir = get_cache_dir()
|
| 17 |
if not os.path.exists(cache_dir):
|
| 18 |
os.makedirs(cache_dir, exist_ok=True)
|
| 19 |
|