mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vfs] more accurate file existence check allows moving broken symlinks (IDEA-143989)
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
+23
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user