Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 44106

Summary: [resources] delete traverses unix symbolic links to directories
Product: [Eclipse Project] Platform Reporter: Jeremiah Lott <jlott1>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: dj.houghton, rebecca, sam.robb
Version: 3.0   
Target Milestone: 3.0 M9   
Hardware: PC   
OS: Unix All   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Jeremiah Lott CLA 2003-10-02 17:37:48 EDT
If my project contains a unix symbolic link to a directory outside the project, 
then deleting the project with contents also deletes the contents of the linked 
directory (recursively).  I would normally expect it to just delete the link, 
and leave the target of the link alone (like the rm command).  It also happens 
if you delete the linked directory in Navigator view.  Symbolic links to 
regular files don't seem to cause a problem.
Comment 1 Jeremiah Lott CLA 2004-02-04 15:47:58 EST
Created attachment 7697 [details]
Proposed patch

This patch seems to fix this problem.  I've used this trick before.  If you
call File.delete() on a symbolic link it deletes just the link, which is what
you want.  So I call that before recursively visiting the child directories. 
If the directory is a non-empty symbolic link, then the newly added call to
delete will return false.  But I ignore that and recur either way.  I hope this
approach will be deemed acceptable, as it causes problems for our Eclipse-based
product.
Comment 2 DJ Houghton CLA 2004-02-06 09:26:41 EST
Investigate for 3.0.

Need to review submitted patch and create associated regression test displaying
failure without the patch and passing with the patch.

Jeremiah, thanks for your contribution!
Comment 3 Sam Robb CLA 2004-04-30 13:20:23 EDT
DJ - any progress on incorporating this patch?  If there's something Jeremiah or
I could do to help this along, we'd be happy to do it.
Comment 4 DJ Houghton CLA 2004-05-04 17:56:23 EDT
Actually its just a matter of me getting time to release the code. Sorry, I've
been working on other things.

I want to write a test case that shows the problem, then apply the patch, and
then run the test case and have it pass.
Comment 5 Steven Blackwell CLA 2004-05-05 09:02:11 EDT
I would think this is a higher priority than P3.  Someone in my company erased 
alot of important calibration data (retrieved via backup) accidentally due to 
this bug.  Managament has not looked favorable on this tool since.
Comment 6 DJ Houghton CLA 2004-05-05 13:32:37 EDT
Fixed and released to HEAD.
Added regression test.
Let me know if you still find problems with your specific use cases.
Closing.
Comment 7 Sam Robb CLA 2004-05-05 14:40:11 EDT
DJ - thanks very much.  I'll take a look at it come M9 and check it against our
test cases.
Comment 8 DJ Houghton CLA 2004-05-05 16:51:07 EDT
Jerimiah is it ok to include your name in the copyright as a contributor? It
would look something like this:

...
 * Contributors:
 * Jeremiah Lott - Fix for Bug 44106 - delete traverses unix symbolic links to
directories
 * IBM Corporation - initial API and implementation
...
Comment 9 Jeremiah Lott CLA 2004-05-10 10:42:55 EDT
I don't mind.  Probably you should list TimeSys Corporation as the contributor, 
however as I did this as part of my employment with them.  Company name seems 
to be the standard.
Comment 10 John Arthorne CLA 2004-10-28 16:48:36 EDT
*** Bug 44112 has been marked as a duplicate of this bug. ***
Comment 11 Matt McCutchen CLA 2007-02-15 00:55:46 EST
This bug seems to have reappeared.  I tested the current CVS Eclipse and it deleted through symbolic links.  Would someone please reopen the bug?  Otherwise I'll file a new one.
Comment 12 DJ Houghton CLA 2007-02-15 09:58:43 EST
Its probably best if you enter a new bug with steps to reproduce, etc since we have a regression test for this and it passes so your case is most likely not the exact same as the original problem. Thanks.
Comment 13 Matt McCutchen CLA 2007-02-15 19:35:53 EST
I figured out why the test passes but yet the bug appears when I delete a symlink to a folder using the Navigator.  The Navigator deletes keeping history, and that causes the local history system to move the files out of the target folder into the local history zone (so it looks just as if they have been deleted).  The test deletes without keeping history.  Should I still file a separate bug?
Comment 14 John Arthorne CLA 2007-02-16 09:40:35 EST
Yes, please enter a new bug.
Comment 15 Matt McCutchen CLA 2007-02-16 14:44:59 EST
OK, I entered bug 174492.