From c1bf2999139a9d7033a89b8ac36ae267cb342e12 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Wed, 6 Nov 2024 13:29:12 +0100 Subject: [PATCH] models.file:File._model_validator - improve check for original path --- acacore/models/file.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/acacore/models/file.py b/acacore/models/file.py index f6ea562..a1411e6 100644 --- a/acacore/models/file.py +++ b/acacore/models/file.py @@ -99,7 +99,12 @@ class File(BaseModel): @classmethod def _model_validator(cls, data: dict): if isinstance(data, dict): - data["original_path"] = data.get("original_path", "").strip() or data["relative_path"] + if (op := data.get("original_path", None)) and isinstance(op, Path): + data["original_path"] = op + elif isinstance(op, str) and op.strip(): + data["original_path"] = Path(op) + else: + data["original_path"] = data["relative_path"] return data # noinspection PyNestedDecorators