diff --git a/src/hatch_openzim/files_install.py b/src/hatch_openzim/files_install.py index 15b98c3..b6a5e00 100644 --- a/src/hatch_openzim/files_install.py +++ b/src/hatch_openzim/files_install.py @@ -194,6 +194,8 @@ def _process_extract_items_action( for index, zip_path in enumerate(zip_paths): item_src = Path(tempdir) / str(zip_path) item_dst = base_target_dir / str(target_paths[index]) + if item_dst.parent and not item_dst.parent.exists(): + item_dst.parent.mkdir(parents=True, exist_ok=True) shutil.move(src=str(item_src), dst=item_dst) if "remove" in action_data: diff --git a/tests/configs/full.toml b/tests/configs/full.toml index 6acd346..eb230c5 100644 --- a/tests/configs/full.toml +++ b/tests/configs/full.toml @@ -38,6 +38,12 @@ source="https://tmp.kiwix.org/ci/hatch_openzim_testsets/testset2.zip" zip_paths=["keep1/file1.txt"] target_paths=["file123.txt"] +[files.part2.actions.action5] +action="extract_items" +source="https://tmp.kiwix.org/ci/hatch_openzim_testsets/testset2.zip" +zip_paths=["keep1/file1.txt"] +target_paths=["action5/subfolder1/file123.txt"] + # part without any actions [files.part3.config] target_dir="part3" diff --git a/tests/test_files_install.py b/tests/test_files_install.py index a045ee9..82c7f7b 100644 --- a/tests/test_files_install.py +++ b/tests/test_files_install.py @@ -20,6 +20,7 @@ def nominal_files(): "part1/somewhere/something.txt", "part1/somewhere_else/something.txt", "part2/file123.txt", + "part2/action5/subfolder1/file123.txt", "part2/action2/file1.txt", "part2/action2/file2.txt", "part2/action3/file1.json",