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>
This commit is contained in:
parent
bad83e5ecd
commit
a29d11775c
|
@ -48,6 +48,7 @@
|
|||
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 LockToken createNewFileAtomic(File file) throws IOException {
|
|||
supportsUnixNLink = false;
|
||||
}
|
||||
return token(true, link);
|
||||
} catch (UnsupportedOperationException | IllegalArgumentException e) {
|
||||
} catch (UnsupportedOperationException | IllegalArgumentException
|
||||
| AccessDeniedException | SecurityException e) {
|
||||
supportsUnixNLink = false;
|
||||
return token(true, link);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue