Skip to content

Commit 1a2effd

Browse files
committed
fix(paths): ensure idempotency in shape and painted path functions
Refactor `_shape_path` and `_painted_path` to normalize the stem using `_base_stem`, ensuring consistent output regardless of input variations. This change addresses idempotency for file naming conventions.
1 parent 822fb11 commit 1a2effd

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

GameAssets/src/gameassets/paths.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,22 @@ def _shape_path(mesh_final: Path) -> Path:
101101
102102
O orquestrador move este ficheiro para ``_intermediate/`` ao fim da
103103
pipeline via ``move_to_intermediate``.
104+
105+
Round 2 fix: normaliza o stem via ``_base_stem`` para que a função seja
106+
idempotente — passar ``goblin.glb`` ou ``goblin_painted.glb`` devolve
107+
sempre ``goblin_shape.glb``.
104108
"""
105-
return mesh_final.with_name(f"{mesh_final.stem}_shape{mesh_final.suffix}")
109+
base = _base_stem(mesh_final.stem)
110+
return mesh_final.with_name(f"{base}_shape{mesh_final.suffix}")
106111

107112

108113
def _painted_path(mesh_final: Path) -> Path:
109-
"""``id_painted.glb`` ao lado da mesh canónica (compat)."""
110-
return mesh_final.with_name(f"{mesh_final.stem}_painted{mesh_final.suffix}")
114+
"""``id_painted.glb`` ao lado da mesh canónica (compat).
115+
116+
Idempotente em relação a sufixos canónicos (Round 2 fix).
117+
"""
118+
base = _base_stem(mesh_final.stem)
119+
return mesh_final.with_name(f"{base}_painted{mesh_final.suffix}")
111120

112121

113122
def _clean_path(mesh_final: Path) -> Path:

0 commit comments

Comments
 (0)