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

Bug 319054

Summary: Eclipse deletes all files when I cancel a project creation (symlink in project location path)
Product: [Eclipse Project] JDT Reporter: Mateus Krepsky Ludwich <mkludwich>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: amj87.iitr, daniel_megert, markus.kell.r, pommessemmel, remy.suen, sampepping
Version: 3.5.2Flags: daniel_megert: review+
Target Milestone: 3.8.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 233019    
Bug Blocks:    

Description Mateus Krepsky Ludwich CLA 2010-07-06 16:32:32 EDT
Build Identifier: 20100218-1602

There were a directory (named "prj_it") which had the following structure:
    aub_o/    
    bin/    
    KNF/
    src/

The path for prj_it in my file system is:
    /home/mateus/dev/prj_it

In /home/mateus there is also a symbolic link (named "prj_it") that points to dev/prj_it 
    
I tried to create a new Java project, using "prj_it" as base. ("Create project from existing source")
I selected the symbolic link prj_it (/home/mateus/prj_it) as the path to the project.

It appears the message: "The output folder has changed. Do you want to remove the old location 'prj_it/bin' and its content?"
So I selected to cancel and I clicked in the "Back" button.
Then all files in all subdirectories of prj_it were gone! The subdirectories (aub_o, bin, KNF, and src) are still there, but now they are empty.

If I select the complete path (/home/mateus/dev/prj_it) instead of the symbolic link, that error does not happen.


Reproducible: Always

Steps to Reproduce:
1. Click on menu File -> New -> Java Project
2. Select the option "Create project from existing source"
3. Click on "Browse" button
4. Select a symbolic link that points to the desired directory and click on "OK" button
5. Click on "Next >" button
It will appear the message: "The output folder has changed. Do you want to remove the old location 'prj_it/bin' and its content?"
6. Click on "Cancel" button
7. Click on "< Back" button
Comment 1 Ayushman Jain CLA 2010-07-07 01:28:49 EDT
Jay, please investigate. Thanks.
Comment 2 Jay Arthanareeswaran CLA 2010-07-12 04:09:42 EDT
Can you please give me the complete build ID (with 'I', 'M' etc) or the build name? 

From the steps you have given, I see that this is one of the older builds. I would recommend that you use a newer, if possible latest, build and see if you still get this problem. In the newer builds, the UI has changed bit around that use-case.
Comment 3 Mateus Krepsky Ludwich CLA 2010-07-17 14:43:48 EDT
(In reply to comment #2)
> Can you please give me the complete build ID (with 'I', 'M' etc) or the build
> name? 
> 
> From the steps you have given, I see that this is one of the older builds. I
> would recommend that you use a newer, if possible latest, build and see if you
> still get this problem. In the newer builds, the UI has changed bit around that
> use-case.

Hi, I don't see any character ('I' or 'M', etc) in the build ID. I just get this:

Eclipse IDE for Java Developers

Version: 1.2.2.20100216-1730
Build id: 20100218-1602

BTW, I'm using Eclipse Galileo (eclipse-java-galileo-SR2-linux-gtk.tar.gz) if it helps.

Oh, I discovered something new: depending on the files that prj_it/bin contains, the message:

"The output folder has changed. Do you want to remove the old location 'prj_it/bin' and its content?", 

described in step number 5, does not appear. But, eclipse still delete my files after I click on "Back" button (as described by step number 7). Again, this only occurs when I select the symbolic link prj_it as the path to the project.

I tried the reproduce the bug using Eclipse Helios (eclipse-java-helios-linux-gtk.tar.gz),

Eclipse IDE for Java Developers

Version: 1.3.0.20100617-0520
Build id: 20100617-1415.

And the bug still occurs!

I putted some screen shots here:
    http://www.inf.ufsc.br/~ludwich/eclipse/

with the steps to reproduce the bug.
Comment 4 Simon Pepping CLA 2010-09-22 09:54:49 EDT
I experience the same problem, now twice accidentally, and I can repeat it easily.

Steps to repeat:

Directory /source/bbb contains
>ls -a
.  ..  bin  .classpath  docs  .project  src

(.classpath and .project come from copying from another eclipse project)

>ls docs
PRV05-2500.xml  waarnemingen.dtd     waarnemingen.xquery~
PRV05-2600.xml  waarnemingen.xquery

File | New Java Project
fill in project name; uncheck 'Use default location'; browse; select /source/bbb;
Next
Cancel

>ls -a
.  ..  bin  .classpath  docs  .project  src

>ls docs

All content in docs (and bin and src) has been wiped out.

Platform: Debian Linux testing. Eclipse: installed from Galileo SR1, updated several times, now to Helios.

Version: Helios Release
Build id: 20100618-0524

*** System properties:
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.buildId=I20100608-0911
eclipse.commands=-os
linux
-ws
gtk
-arch
x86
-showsplash
/fsb/local/eclipse//plugins/org.eclipse.platform_3.6.0.v201006080911/splash.bmp
-launcher
/fsb/local/eclipse/eclipse
-name
Eclipse
--launcher.library
/fsb/local/eclipse//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.0.v20100503/eclipse_1307.so
-startup
/fsb/local/eclipse//plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
-product
org.eclipse.epp.package.java.product
-vm
/usr/lib/jvm/java-6-sun-1.6.0.21/jre/bin/../lib/i386/client/libjvm.so

This happened once before the upgrade to Helios, and once after.

It can be repeated easily, but not always. It seems that if the name of the directory has been used earlier to register a project (cancelled or not), the contents of the subdirectories are not deleted.

This is a highly critical bug, because it does not concern eclipse functionality, but the deletion of user content.

If the new project is a git working directory, the whole history of the project contained in the .git subdirectory is wiped out. Shudder.
Comment 5 Dani Megert CLA 2012-11-08 05:30:51 EST
*** Bug 393796 has been marked as a duplicate of this bug. ***
Comment 6 Markus Keller CLA 2012-12-18 14:09:02 EST
Reproduced in master with the steps from comment 0.

The crucial point is to create the project outside of the workspace at location
    /home/mateus/prj_it
, which is a symbolic link to
    /home/mateus/dev/prj_it

The problem is that NewJavaProjectWizardPageTwo#rememberExisitingFolders(URI) operates on the original location, but #restoreExistingFolders(URI) gets the resolved location that includes "dev/". On cancel, that method doesn't find the original folders any more. It wrongly assumes the existing folders have been created in the wizard and then goes and deletes them.

The symlink in the project location gets resolved in Project#create(..) via FileUtil.canonicalURI(..). This behavior is unspecified, see bug 233019.
Comment 7 Markus Keller CLA 2012-12-19 10:15:26 EST
Released workaround to master: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=a0d2d3a64f310e7775834de993b511bac2dd2a99

Unless bug 233019 gets fixed for 4.2.2, we should backport this.
Comment 8 Markus Keller CLA 2013-01-03 10:36:54 EST
Looking at the history of bug 233019, I doubt this will be addressed for 4.2.2.
Dani, OK for 3.8.2?
Comment 9 Dani Megert CLA 2013-01-07 08:45:39 EST
(In reply to comment #8)
> Looking at the history of bug 233019, I doubt this will be addressed for
> 4.2.2.
> Dani, OK for 3.8.2?

Yes, looks good except for the copyright date. And make sure to increase the bundle version.
Comment 11 Dani Megert CLA 2013-01-17 10:04:21 EST
Verified in 3.8-M20130116-1030 and 4.2-M20130116-1800 on Ubuntu and Windows 7.
Comment 12 Dani Megert CLA 2013-01-17 12:05:46 EST
We also verified that it works using junctions and symbolic links under Windows and that it also worked there before this fix was applied.