Skip to content

Commit

Permalink
Fix the bootstrap reinstallation logic for when PREFIX is a symlink
Browse files Browse the repository at this point in the history
Changes were made to bootstrap reinstallation logic in 107927f, but it wasn't considering that PREFIX may be a symlink file to a directory instead of a directory file. With this commit, the previous behaviour of termux is restored where PREFIX can optionally be a symlink to a valid directory where the symlink isn't broken/dangling.
  • Loading branch information
agnostic-apollo committed Apr 21, 2021
1 parent 0fe608f commit b34f60b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/termux/app/TermuxInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static void setupBootstrapIfNeeded(final Activity activity, final Runnable whenD
final String PREFIX_FILE_PATH = TermuxConstants.TERMUX_PREFIX_DIR_PATH;
final File PREFIX_FILE = TermuxConstants.TERMUX_PREFIX_DIR;

// If prefix directory exists
if (FileUtils.directoryFileExists(PREFIX_FILE_PATH, false)) {
// If prefix directory exists, even if its a symlink to a valid directory and symlink is not broken/dangling
if (FileUtils.directoryFileExists(PREFIX_FILE_PATH, true)) {
File[] PREFIX_FILE_LIST = PREFIX_FILE.listFiles();
// If prefix directory is empty or only contains the tmp directory
if(PREFIX_FILE_LIST == null || PREFIX_FILE_LIST.length == 0 || (PREFIX_FILE_LIST.length == 1 && TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH.equals(PREFIX_FILE_LIST[0].getAbsolutePath()))) {
Expand Down

0 comments on commit b34f60b

Please sign in to comment.