Fix the bootstrap reinstallation logic for when PREFIX is a symlink

Changes were made to bootstrap reinstallation logic in 107927f5, 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.
This commit is contained in:
agnostic-apollo
2021-04-21 14:06:57 +05:00
parent 0fe608f91e
commit b34f60b1b0

View File

@@ -65,8 +65,8 @@ final class TermuxInstaller {
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()))) {