Sort files list in FileDirectory::loadAll() (#3657)

This lets us assemble classes.dex in a reproducible manner.

Test:
  apktool d test.apk > /dev/null
  apktool b test > /dev/null
  sha1sum test/build/apk/classes.dex
  apktool -f d test.apk > /dev/null
  apktool b test > /dev/null
  sha1sum test/build/apk/classes.dex
This commit is contained in:
luk1337 2024-08-13 01:17:50 +02:00 committed by GitHub
parent 7ad1c9f9b4
commit 9ebd579475
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,8 @@ package brut.directory;
import java.io.*;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@ -107,6 +109,8 @@ public class FileDirectory extends AbstractDirectory {
mDirs = new LinkedHashMap<>();
File[] files = getDir().listFiles();
Arrays.sort(files, Comparator.comparing(f -> f.getName()));
for (File file : files) {
if (file.isFile()) {
mFiles.add(file.getName());