Skip to content

Commit d783177

Browse files
committed
Build hook: fix issue with extract_items when target_path is in a subfolder
1 parent 1c16896 commit d783177

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Metadata hook: add suport for additional-classifiers property #10
1313

14+
### Fixed
15+
16+
- Build hook: fix issue with extract_items when target_path is in a subfolder #11
17+
1418
## [0.1.0] - 2024-02-05
1519

1620
### Added

src/hatch_openzim/files_install.py

+2
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ def _process_extract_items_action(
194194
for index, zip_path in enumerate(zip_paths):
195195
item_src = Path(tempdir) / str(zip_path)
196196
item_dst = base_target_dir / str(target_paths[index])
197+
if item_dst.parent and not item_dst.parent.exists():
198+
item_dst.parent.mkdir(parents=True, exist_ok=True)
197199
shutil.move(src=str(item_src), dst=item_dst)
198200

199201
if "remove" in action_data:

tests/configs/full.toml

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ source="https://tmp.kiwix.org/ci/hatch_openzim_testsets/testset2.zip"
3838
zip_paths=["keep1/file1.txt"]
3939
target_paths=["file123.txt"]
4040

41+
[files.part2.actions.action5]
42+
action="extract_items"
43+
source="https://tmp.kiwix.org/ci/hatch_openzim_testsets/testset2.zip"
44+
zip_paths=["keep1/file1.txt"]
45+
target_paths=["action5/subfolder1/file123.txt"]
46+
4147
# part without any actions
4248
[files.part3.config]
4349
target_dir="part3"

tests/test_files_install.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def nominal_files():
2020
"part1/somewhere/something.txt",
2121
"part1/somewhere_else/something.txt",
2222
"part2/file123.txt",
23+
"part2/action5/subfolder1/file123.txt",
2324
"part2/action2/file1.txt",
2425
"part2/action2/file2.txt",
2526
"part2/action3/file1.json",

0 commit comments

Comments
 (0)