diff options
author | 2017-06-01 12:35:47 +0200 | |
---|---|---|
committer | 2017-06-01 14:09:06 +0200 | |
commit | 6c07525462062d491816a66a94c3db3b2dbc8f98 (patch) | |
tree | 2acea2b3688bf48d58ed426c060618fa51952276 /src | |
parent | a4697fdc1372adc6189abda0990e9ffd7ed00d63 (diff) |
Windows: Create a dangling junction when symlink target doesn't exist
On Unix system, `ln -s foo bar` will create an dangling symlink bar -> foo
even foo doesn't exist. The current implementation of createSymbolicLink for
Windows fails in this situtation. And this lead to #2474.
In this change, we create a dangling junction when the target doesn't exist
which mimics the behavior on Unix.
Fixed https://github.com/bazelbuild/bazel/issues/2474
Change-Id: I442ca3e2fb20b76c9b5bbfee903299fe51481f43
PiperOrigin-RevId: 157694631
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/windows/WindowsFileSystem.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/windows/WindowsFileSystem.java b/src/main/java/com/google/devtools/build/lib/windows/WindowsFileSystem.java index 77197d7c41..c3a9095082 100644 --- a/src/main/java/com/google/devtools/build/lib/windows/WindowsFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/windows/WindowsFileSystem.java @@ -347,7 +347,8 @@ public class WindowsFileSystem extends JavaIoFileSystem { try { java.nio.file.Path link = getIoFile(linkPath).toPath(); java.nio.file.Path target = getIoFile(targetPath).toPath(); - if (target.toFile().isDirectory()) { + // Still Create a dangling junction if the target doesn't exist. + if (!target.toFile().exists() || target.toFile().isDirectory()) { WindowsFileOperations.createJunction(link.toString(), target.toString()); } else { Files.copy(target, link); |