diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java index 918bf33d3822..0e249c5d6089 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java @@ -516,7 +516,7 @@ public abstract class LocalFileSystemBase extends LocalFileSystem { } File ioFile = convertToIOFile(file); - if (!ioFile.exists()) { + if (FileSystemUtil.getAttributes(ioFile) == null) { throw new FileNotFoundException(VfsBundle.message("file.not.exist.error", ioFile.getPath())); } File ioParent = convertToIOFile(newParent); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java index 02384edb0ab2..f6d2e10ed117 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java @@ -37,6 +37,7 @@ import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl; import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; @@ -638,4 +639,26 @@ public class LocalFileSystemTest extends PlatformTestCase { } }.execute(); } + + public void testBrokenSymlinkMove() throws IOException, InterruptedException { + final File srcDir = IoTestUtil.createTestDir("src"); + final File link = IoTestUtil.createSymLink(srcDir.getPath() + "/missing", srcDir.getPath() + "/link", false); + final File dstDir = IoTestUtil.createTestDir("dst"); + + new WriteAction() { + @Override + protected void run(@NotNull Result result) throws Throwable { + VirtualFile file = myFS.refreshAndFindFileByIoFile(link); + assertNotNull(file); + + VirtualFile target = myFS.refreshAndFindFileByIoFile(dstDir); + assertNotNull(target); + + myFS.moveFile(this, file, target); + } + }.execute(); + + assertOrderedEquals(ArrayUtil.EMPTY_STRING_ARRAY, srcDir.list()); + assertOrderedEquals(new String[]{link.getName()}, dstDir.list()); + } }