Browse Source

FS_POSIX: handle Files.getFileStore() failures

Android unconditionally throws a SecurityException;[1] getFileStore()
is not supported. Catch the exception and don't attempt the hard-
linking atomic file mechanism.

[1] https://android.googlesource.com/platform/libcore/+/21e6175e25

Bug: 548947
Change-Id: Idfba2d9dbcbc80ea15ab2ae7889e5142444c1581
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
stable-5.4
Thomas Wolf 5 years ago committed by Matthias Sohn
parent
commit
aefb11298c
  1. 14
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

14
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

@ -396,7 +396,12 @@ public class FS_POSIX extends FS {
}
Path lockPath = lock.toPath();
Path link = null;
FileStore store = Files.getFileStore(lockPath);
FileStore store = null;
try {
store = Files.getFileStore(lockPath);
} catch (SecurityException e) {
return true;
}
try {
Boolean canLink = CAN_HARD_LINK.computeIfAbsent(store,
s -> Boolean.TRUE);
@ -462,7 +467,12 @@ public class FS_POSIX extends FS {
}
Path link = null;
Path path = file.toPath();
FileStore store = Files.getFileStore(path);
FileStore store = null;
try {
store = Files.getFileStore(path);
} catch (SecurityException e) {
return token(true, null);
}
try {
Boolean canLink = CAN_HARD_LINK.computeIfAbsent(store,
s -> Boolean.TRUE);

Loading…
Cancel
Save