fix: 🩹 skip indexing really large files

This commit is contained in:
Nate Sesti 2023-07-27 10:28:35 -07:00
parent d66fb0f014
commit b773fe6d7a

View file

@ -6,12 +6,20 @@ from ...core.context import ContextProvider
from fnmatch import fnmatch
MAX_SIZE_IN_BYTES = 1024 * 1024 * 1
def get_file_contents(filepath: str) -> str:
try:
filesize = os.path.getsize(filepath)
if filesize > MAX_SIZE_IN_BYTES:
print("File is over 1MB size limit: ", filepath, filesize)
return ""
with open(filepath, "r") as f:
return f.read()
except Exception as e:
print("Error reading file contents", e)
print("Error reading file contents", filepath, e)
return ""