Skip to content

Commit

Permalink
Build hook: fix issue with extract_items when target_path is in a sub…
Browse files Browse the repository at this point in the history
…folder
  • Loading branch information
benoit74 committed Feb 14, 2024
1 parent a2a65f1 commit 3e7f119
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hatch_openzim/files_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/configs/full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/test_files_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3e7f119

Please sign in to comment.