Skip to content

Support zipping empty directories #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 17, 2025
Merged

Conversation

kiendang
Copy link
Contributor

@kiendang kiendang commented Mar 5, 2025

Currently empty directories are excluded when zipping.

@lihaoyi
Copy link
Member

lihaoyi commented Mar 7, 2025

So my understanding of the expected behavior from the current docs (https://github.com/com-lihaoyi/os-lib#oszip) is that folders directly referenced in the zip call's sourcePaths are unpacked into the root of the zip by default, unless they are given an explicit destination path in the zip via -> os.sub / "renamed-folder"

In that case, ignoring empty directories as shown in your test case os.zip(sources = Seq(emptyDir, outerEmptyDir)) seems like the right thing to do, and this change would make it inconsistent with the behavior for non-empty directories

@kiendang
Copy link
Contributor Author

kiendang commented Mar 7, 2025

I see. Updated the PR to handle zipping empty directories

  • specified in sources
    • without dest -> ignored
    • with dest -> included
  • inside one of the sources -> included

In cases that empty directories are included in the zip, their names should also follow includePatterns/excludePatterns?

@lihaoyi
Copy link
Member

lihaoyi commented Mar 7, 2025

@kiendang good question about the includePatterns/excludePatterns. What does the unix zip command do?

@kiendang
Copy link
Contributor Author

kiendang commented Mar 7, 2025

Yup the zip command on Mac does support -x/-i for empty directories. Updated.

@lihaoyi lihaoyi merged commit 341e86b into com-lihaoyi:main Mar 17, 2025
15 of 16 checks passed
@kiendang kiendang deleted the zip-empty-dir branch March 18, 2025 13:56
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