mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-12-03 15:41:07 +01:00
Improve setup of symlinks to external storage
The context.getExternalFilesDirs(null) call may return several elements, and some of them may be null.
This commit is contained in:
parent
6334470f81
commit
357b17e972
1 changed files with 7 additions and 3 deletions
|
|
@ -257,9 +257,13 @@ final class TermuxInstaller {
|
|||
Os.symlink(moviesDir.getAbsolutePath(), new File(storageDir, "movies").getAbsolutePath());
|
||||
|
||||
final File[] dirs = context.getExternalFilesDirs(null);
|
||||
if (dirs != null && dirs.length >= 2) {
|
||||
final File externalDir = dirs[1];
|
||||
Os.symlink(externalDir.getAbsolutePath(), new File(storageDir, "external").getAbsolutePath());
|
||||
if (dirs != null && dirs.length > 1) {
|
||||
for (int i = 1; i < dirs.length; i++) {
|
||||
File dir = dirs[i];
|
||||
if (dir == null) continue;
|
||||
String symlinkName = "external-" + i;
|
||||
Os.symlink(dir.getAbsolutePath(), new File(storageDir, symlinkName).getAbsolutePath());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Error setting up link", e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue