Skip to content

Preserve empty child directories in ZIP and TAR archives - #205

Merged
fabiocaccamo merged 4 commits into
fabiocaccamo:mainfrom
UmutAlisoglu:codex/preserve-empty-archive-directories
Nov 27, 2026
Merged

fabiocaccamo merged 4 commits into
fabiocaccamo:mainfrom
UmutAlisoglu:codex/preserve-empty-archive-directories

Conversation

@UmutAlisoglu

Copy link
Copy Markdown
Contributor

Describe your changes

Empty child directories disappear when a directory is archived with create_zip_file() or create_tar_file() and then extracted. Both writers recurse through directory contents but only write file entries.

Write an explicit entry for an empty child directory. Keep the existing contents-only layout for each input directory and the existing paths for files. The regression performs ZIP and TAR round trips with an empty directory, a nested empty directory and a nonempty sibling file.

Related issue

No matching issue or PR found. Both round-trip regressions fail on current main because the empty directories are missing after extraction. This is independent of the local-filename fix in #204.

Validation

  • Windows / Python 3.14.7: full suite, 304 passed and 3 platform skips.
  • Total coverage: 98.41%, above the required 90%.
  • All applicable pinned pre-commit hooks pass, including Ruff and mypy.

Checklist before requesting a review

  • I have performed a self-review of my code. (AI-assisted; no human review claimed.)
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

AI-assisted with OpenAI Codex, including investigation, implementation and verification.

@UmutAlisoglu

Copy link
Copy Markdown
Contributor Author

The Codacy report flags three assertions in tests/test_archives.py (lines 52–54) under Bandit's "Avoid Use of Assert Statements" rule. These are pytest test assertions, following the existing test suite's style, rather than runtime validation in the library.

Could this rule be excluded for tests/ in the Codacy configuration, or these test-only findings marked as false positives? I've left the assertions intact so pytest keeps its normal failure introspection.

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.60%. Comparing base (6166c7e) to head (d5ae30f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #205   +/-   ##
=======================================
  Coverage   98.59%   98.60%           
=======================================
  Files          13       13           
  Lines         854      858    +4     
=======================================
+ Hits          842      846    +4     
  Misses         12       12           
Flag Coverage Δ
unittests 98.60% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# Conflicts:
#	src/fsutil/archives.py
@fabiocaccamo
fabiocaccamo merged commit dc71e36 into fabiocaccamo:main Nov 27, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants