Browse Source

Atomic file creation: hard-linking may not be allowed

Android for instance forbids hard linking via a SELinux
policy. If we can't hard link, the NFS work-around for
atomic file creation cannot work at all. In this case,
fall back to not using the hard-linking mechanism.

Android throws an AccessDeniedException, so we catch that.
The javadoc on Files.createLink() indicates that another
possibility might be a SecurityException, so catch that,
too.

Bug: 543956
Change-Id: I551b7a45f7b2fbbd8cf94f0b7233dbd8a200520e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
stable-5.4
Thomas Wolf 6 years ago committed by Matthias Sohn
parent
commit
a29d11775c
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

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

@ -48,6 +48,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.file.AccessDeniedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -463,7 +464,8 @@ public class FS_POSIX extends FS {
supportsUnixNLink = false;
}
return token(true, link);
} catch (UnsupportedOperationException | IllegalArgumentException e) {
} catch (UnsupportedOperationException | IllegalArgumentException
| AccessDeniedException | SecurityException e) {
supportsUnixNLink = false;
return token(true, link);
}

Loading…
Cancel
Save