LuciferYang commented on code in PR #49347:
URL: https://github.com/apache/spark/pull/49347#discussion_r1901677557


##########
core/src/test/scala/org/apache/spark/util/UtilsSuite.scala:
##########
@@ -731,6 +732,52 @@ class UtilsSuite extends SparkFunSuite with 
ResetSystemProperties {
     assert(!sourceFile2.exists())
   }
 
+  test("SPARK-50716: deleteRecursively - SymbolicLink To File") {
+    val tempDir = Utils.createTempDir()
+    val sourceFile = new File(tempDir, "foo.txt")
+    JFiles.write(sourceFile.toPath, "Some content".getBytes)
+    assert(sourceFile.exists())
+
+    val targetDir = new File(tempDir, "targetDir")
+    assert(targetDir.mkdir())
+
+    val symlinkFile = new File(targetDir, "target.txt")
+    JFiles.createSymbolicLink(symlinkFile.toPath, sourceFile.toPath)
+
+    // Check that the symlink was created successfully
+    assert(JFiles.isSymbolicLink(symlinkFile.toPath))
+    Utils.deleteRecursively(tempDir)
+
+    // Verify that everything is deleted
+    assert(!tempDir.exists)
+    assert(!sourceFile.exists)
+    assert(!targetDir.exists)
+    assert(!symlinkFile.exists)
+  }
+
+  test("SPARK-50716: deleteRecursively - SymbolicLink To Dir") {

Review Comment:
   This test case would fail without the current pr  because, without 
specifying `LinkOption.NOFOLLOW_LINKS`, the `symlinkDir` cannot enter the 
branch `if (fileAttributes.isDirectory() && !isSymlink(file))`. 
   
   However, `symlinkDir` is not an empty directory too, so there is no logic to 
delete it, which will result in residuals.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to