cannot import non-text files!
build / build (push) Successful in 39s
pytest / pytest (push) Successful in 35s

This commit is contained in:
2026-04-24 18:40:51 +02:00
parent c6ad060e85
commit d71fce7a6a
3 changed files with 51 additions and 1 deletions
+8
View File
@@ -2,11 +2,14 @@ from __future__ import annotations
import os
from pathlib import Path
from plistlib import InvalidFileException
from rich import print
from chromy.utilities import ingest_file
from ..utilities import is_probably_text_file
def _get_absolute_path(file: str) -> str:
"""
@@ -27,6 +30,11 @@ def _get_absolute_path(file: str) -> str:
def handle_import(collection: str, file: str) -> int:
absolute_path = _get_absolute_path(file)
if not is_probably_text_file(absolute_path):
raise InvalidFileException()
records_added = ingest_file(collection, _get_absolute_path(file))
print(f"[bold green]Added[/] {records_added} records to collection '{collection}'.")
return 0