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

Bug 339814

Summary: Move project to subdirectory deletes contents
Product: [Eclipse Project] Platform Reporter: Robin Rosenberg <robin.rosenberg>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: critical    
Priority: P3 CC: yevshif
Version: 3.6.2   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Screen shot none

Description Robin Rosenberg CLA 2011-03-13 00:30:06 EST
Say you created a project and want to move it one level down.

/path/to/Location
/path/to/Location/BetterLocation

You can attempt this with Refactor/Move and enter the new path.

Eclipse will now delete the project, leaving only a .project file at BetterLocation. Everything else
is deleted.

Internallly Eclipse tries a File.renameTo, which fails. Then it performs a copy from Location
to BetterLocation followed by a delete of Location (oops).
Comment 1 John Arthorne CLA 2011-05-27 17:06:41 EDT
Created attachment 196813 [details]
Screen shot

When I try this, the dialog will not allow me to move the project to a sub-directory of itself. What version of Eclipse are you using, and how are you trying to move it?
Comment 2 Robin Rosenberg CLA 2011-05-27 17:59:48 EDT
Heres an exact procedure

Start with empty workspace.

Create a Java Project P in the workspace.

See what it contains.

$ find /Users/me/Documents/workspace/P
/Users/me/Documents/workspace/P
/Users/me/Documents/workspace/P/.classpath
/Users/me/Documents/workspace/P/.project
/Users/me/Documents/workspace/P/.settings
/Users/me/Documents/workspace/P/.settings/org.eclipse.jdt.core.prefs
/Users/me/Documents/workspace/P/bin
/Users/me/Documents/workspace/P/src

Select Refactor/Move and enter add /Q to the path. In my case:

/Users/me/Documents/workspace/P/Q

Eclipse 3.6 does NOT prevent this. During typing you wil se the error message
tha prevents the move (i.e. after /, but not after Q). Often the error message
appears and the move is prevented, but not always.

Eclipse says it moved the project.

Now look at the cotent again:

$ find /Users/me/Documents/workspace/P
/Users/me/Documents/workspace/P
/Users/me/Documents/workspace/P/Q
/Users/me/Documents/workspace/P/Q/.project
/Users/me/Documents/workspace/P/Q/bin
/Users/me/Documents/workspace/P/Q/bin/.project

Most file missing. I guess the .project files comes from Eclipse actually creating them after the move.

Eclipse Version: 3.6.2 Build id: M20110210-1200
Comment 3 John Arthorne CLA 2011-05-30 09:11:02 EDT
Thanks for the details.

*** This bug has been marked as a duplicate of bug 307140 ***