fix: create parent directories for targets in subfolders

Build targets with subfolder paths (e.g. img/file.jpg) failed because
parent directories did not exist. Create them on demand in
_build_single_target before dispatching to providers.

Also clean up empty subdirectories in the clean command after removing
target files.
This commit is contained in:
Konstantin Fickel 2026-02-21 11:21:51 +01:00
parent 8f0e49ee6f
commit d22b524182
Signed by: kfickel
GPG key ID: A793722F9933C1A5
2 changed files with 17 additions and 0 deletions

View file

@ -145,6 +145,9 @@ async def _build_single_target(
provider_index: dict[str, Provider],
) -> None:
"""Build a single target by dispatching to the appropriate provider."""
# Ensure parent directories exist for targets in subfolders.
(project_dir / target_name).parent.mkdir(parents=True, exist_ok=True)
target_cfg = config.targets[target_name]
if isinstance(target_cfg, DownloadTargetConfig):