Skip to content

chore: allow outputting to folder if its empty - #4188

Open
iTrooz wants to merge 3 commits into
iBotPeaches:mainfrom
iTrooz:check_empty
Open

chore: allow outputting to folder if its empty#4188
iTrooz wants to merge 3 commits into
iBotPeaches:mainfrom
iTrooz:check_empty

Conversation

@iTrooz

@iTrooz iTrooz commented Jul 26, 2026

Copy link
Copy Markdown

Very small PR, just allows you to output to a directory that is empty :)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ApkDecoder.decode(File outDir) to allow decoding into an output directory that already exists as long as it is empty, aligning behavior with the PR’s intent of permitting “empty folder” outputs without requiring -f.

Changes:

  • Adjust output-directory existence check to permit existing empty directories.
  • Continue to block decoding into non-empty output directories unless forced.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java Outdated
Comment thread brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java Outdated
iTrooz and others added 2 commits July 26, 2026 12:10
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@IgorEisberg

IgorEisberg commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

The test is an overkill. You're also using a completely unrelated test issue2701.apk for this. That's confusing.
I'm not a fan of using File.listFiles for this, it's heavy and we're only interested in stopping after first match, not allocating a potentially huge array of files.
There's a better way to achieve this, one of them is deleting the folder using rmfile after checking that it's a directory and not a symlink, then rechecking if it still exists. (If the folder was not empty, rmfile fails silently).
The other option is using a DirectoryStream and just calling stream.iterator().hasNext(). This immediately stops after first match.

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.

3 participants