Skip to content

Commit

Permalink
Make less assumptions about installer zip structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed May 5, 2024
1 parent 49fd8f1 commit 3a06443
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/src/main/java/com/termux/app/TermuxInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public void run() {
if (isDirectory) {
targetFile.mkdirs();
} else {
File parentDir = targetFile.getParentFile();
if (!parentDir.exists() && !parentDir.mkdirs()) {
throw new RuntimeException("Cannot create parent dir for: " + targetFile.getAbsolutePath());
}
try (FileOutputStream outStream = new FileOutputStream(targetFile)) {
int readBytes;
while ((readBytes = zipInput.read(buffer)) != -1)
Expand All @@ -140,6 +144,10 @@ public void run() {
}

for (Pair<String, String> symlink : symlinks) {
var linkFile = new File(symlink.second);
if (!linkFile.getParentFile().exists() && !linkFile.getParentFile().mkdirs()) {
throw new RuntimeException("Cannot create dir: " + linkFile.getParentFile());
}
Os.symlink(symlink.first, symlink.second);
}

Expand Down

0 comments on commit 3a06443

Please sign in to comment.