mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-114633 (symlink deletion regression fixed)
This commit is contained in:
+6
-6
@@ -35,7 +35,7 @@ import java.util.jar.JarOutputStream;
|
||||
* @since 1/15/13 7:26 PM
|
||||
*/
|
||||
public class RefConvertorsTest extends LightCodeInsightTestCase {
|
||||
|
||||
|
||||
private File myExtractedImagesDir;
|
||||
|
||||
@Override
|
||||
@@ -47,7 +47,7 @@ public class RefConvertorsTest extends LightCodeInsightTestCase {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtilRt.delete(myExtractedImagesDir);
|
||||
FileUtil.delete(myExtractedImagesDir);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ public class RefConvertorsTest extends LightCodeInsightTestCase {
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
String textBefore =
|
||||
|
||||
String textBefore =
|
||||
"<HTML>" +
|
||||
"java.lang.Object\n" +
|
||||
" <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" +
|
||||
"</HTML>";
|
||||
|
||||
|
||||
File f = new File(myExtractedImagesDir, imgJarName);
|
||||
f = new File(f, "resources");
|
||||
File extractedImgFile = new File(f, "inherit.gif");
|
||||
@@ -88,7 +88,7 @@ public class RefConvertorsTest extends LightCodeInsightTestCase {
|
||||
"</HTML>",
|
||||
LocalFileSystem.PROTOCOL_PREFIX,
|
||||
extractedImgFile.getAbsolutePath());
|
||||
|
||||
|
||||
JavaDocExternalFilter filter = new JavaDocExternalFilter(getProject());
|
||||
String textAfter = filter.correctRefs(
|
||||
String.format("%s%s!/org/bouncycastle/asn1/BERSequenceParser.html", JarFileSystem.PROTOCOL_PREFIX, imgJar.getAbsolutePath()),
|
||||
|
||||
@@ -444,19 +444,15 @@ public class FileUtilRt {
|
||||
|
||||
public static boolean delete(@NotNull File file) {
|
||||
if (file.isDirectory()) {
|
||||
if (!deleteChildren(file)) return false;
|
||||
}
|
||||
return deleteFile(file);
|
||||
}
|
||||
|
||||
protected static boolean deleteChildren(@NotNull File file) {
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
for (File child : files) {
|
||||
if (!delete(child)) return false;
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
for (File child : files) {
|
||||
if (!delete(child)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
return deleteFile(file);
|
||||
}
|
||||
|
||||
public interface RepeatableIOOperation<T, E extends Throwable> {
|
||||
|
||||
@@ -417,7 +417,12 @@ public class FileUtil extends FileUtilRt {
|
||||
if (attributes == null) return true;
|
||||
|
||||
if (attributes.isDirectory() && !attributes.isSymLink()) {
|
||||
if (!deleteChildren(file)) return false;
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
for (File child : files) {
|
||||
if (!delete(child)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return deleteFile(file);
|
||||
|
||||
@@ -210,4 +210,17 @@ public class FileUtilHeavyTest {
|
||||
FileUtilRt.doIOOperation(lastShot);
|
||||
assertEquals(10, lastShot.count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSymlinkDeletion() throws Exception {
|
||||
File targetDir = IoTestUtil.createTestDir(myTempDirectory, "link_del_test_1");
|
||||
IoTestUtil.createTestFile(targetDir, "file");
|
||||
File linkDir = IoTestUtil.createTestDir(myTempDirectory, "link_del_test_2");
|
||||
IoTestUtil.createTestFile(linkDir, "file");
|
||||
IoTestUtil.createSymLink(targetDir.getPath(), linkDir.getPath() + "/link");
|
||||
|
||||
assertEquals(1, targetDir.list().length);
|
||||
FileUtil.delete(linkDir);
|
||||
assertEquals(1, targetDir.list().length);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user