Pārlūkot izejas kodu

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>
tags/v5.3.0.201903061415-rc1
Thomas Wolf pirms 5 gadiem
vecāks
revīzija
a29d11775c

+ 3
- 1
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java Parādīt failu

@@ -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);
}

Notiek ielāde…
Atcelt
Saglabāt