Also keep 10% free so 64gb/128gb EON will still engage when full

pull/1076/head
Willem Melching 2020-02-10 18:35:10 -08:00
parent 64a2d0c3e9
commit de6d73599b
1 changed files with 7 additions and 3 deletions

View File

@ -3,15 +3,19 @@ import os
import shutil
import threading
from selfdrive.swaglog import cloudlog
from selfdrive.loggerd.config import ROOT, get_available_bytes
from selfdrive.loggerd.config import ROOT, get_available_bytes, get_available_percent
from selfdrive.loggerd.uploader import listdir_by_creation
MIN_BYTES = 5 * 1024 * 1024 * 1024
MIN_PERCENT = 10
def deleter_thread(exit_event):
while not exit_event.is_set():
available_bytes = get_available_bytes()
out_of_bytes = get_available_bytes(default=MIN_BYTES + 1) < MIN_BYTES
out_of_percent = get_available_percent(default=MIN_PERCENT + 1) < MIN_PERCENT
if available_bytes is not None and available_bytes < (5 * 1024 * 1024 * 1024):
if out_of_percent or out_of_bytes:
# remove the earliest directory we can
dirs = listdir_by_creation(ROOT)
for delete_dir in dirs: