Skip to content

Commit

Permalink
models.file:File._model_validator - improve check for original path
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Nov 6, 2024
1 parent 42c7fa8 commit c1bf299
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion acacore/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c1bf299

Please sign in to comment.