mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
fix cache cleanup (fixes #1231)
This commit is contained in:
parent
f9457be109
commit
09b0068d16
@ -123,7 +123,7 @@ class EventProcessor(threading.Thread):
|
|||||||
|
|
||||||
# if we are still using more than 90% of the cache, proactively cleanup
|
# if we are still using more than 90% of the cache, proactively cleanup
|
||||||
cache_usage = shutil.disk_usage("/tmp/cache")
|
cache_usage = shutil.disk_usage("/tmp/cache")
|
||||||
if (
|
while (
|
||||||
cache_usage.used / cache_usage.total > 0.9
|
cache_usage.used / cache_usage.total > 0.9
|
||||||
and cache_usage.free < 200000000
|
and cache_usage.free < 200000000
|
||||||
and len(self.cached_clips) > 0
|
and len(self.cached_clips) > 0
|
||||||
@ -133,10 +133,7 @@ class EventProcessor(threading.Thread):
|
|||||||
"Consider increasing space available at /tmp/cache or reducing max_seconds in your clips config."
|
"Consider increasing space available at /tmp/cache or reducing max_seconds in your clips config."
|
||||||
)
|
)
|
||||||
logger.warning("Proactively cleaning up the cache...")
|
logger.warning("Proactively cleaning up the cache...")
|
||||||
while cache_usage.used / cache_usage.total > 0.9:
|
oldest_clip = min(self.cached_clips.values(), key=lambda x: x["start_time"])
|
||||||
oldest_clip = min(
|
|
||||||
self.cached_clips.values(), key=lambda x: x["start_time"]
|
|
||||||
)
|
|
||||||
del self.cached_clips[oldest_clip["path"]]
|
del self.cached_clips[oldest_clip["path"]]
|
||||||
os.remove(os.path.join(CACHE_DIR, oldest_clip["path"]))
|
os.remove(os.path.join(CACHE_DIR, oldest_clip["path"]))
|
||||||
cache_usage = shutil.disk_usage("/tmp/cache")
|
cache_usage = shutil.disk_usage("/tmp/cache")
|
||||||
|
Loading…
Reference in New Issue
Block a user