Bug 2472 - [UI] Impossible to delete a read only project (1GF7Y2S)
Summary: [UI] Impossible to delete a read only project (1GF7Y2S)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0 M2   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:37 EDT by Tod Creasey CLA
Modified: 2002-01-03 13:51 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2001-10-10 22:37:03 EDT
If you create a project pointing at a directory where all of the contents are read only you cannot
be rid of it.

STEPS
	1) Create a project Foo whose location is your CD ROM drive
	2) Select delete on Foo. It will ask if you want to delete the contents from the file system.
	3) Say no - you will now get prompted for each one being deleted.
	4) No matter what you cannot get rid of Foo


NOTES:

TC (6/12/01 1:49:17 PM) - interestingly this works fine if you choose to do the same thing on a 
read only file on the file system. Just select yes to deletion and it deletes the resource but
leaves the file alone.

SA (10/10/2001 10:34:40 AM)
	In build 0.202, this problem still exist. Here some more details on what is going on. When
	a project is created and its location points to a read-only directory (and all files contained in
	the directory is read-only), the equivalent resouces are created in the workspace with the
	read-only flag on. So when you delete the project, the first dialog prompts if you want to delete
	the actual files and directories in the file system. The next prompt you get is if you want to
	delete the read-only resource project in the workspace (you also get prompted for all
	the resources in the project if they are read-only also).

	I guess the confusion comes from the message in the prompts? I too was fooled
	the first time I ran this. At the very least, we need to update the messages in the
	prompts (maybe add the words "project" or "workspace resource", etc). Or maybe
	we should change how this is presented to the user? (no ideas at the moment of
	course).
Comment 1 DJ Houghton CLA 2001-10-29 18:30:18 EST
PRODUCT VERSION: 122


Comment 2 Nick Edgar CLA 2001-12-11 10:52:41 EST
Wasn't this one fixed in the 1.0 patch?
Comment 3 Tod Creasey CLA 2001-12-11 11:09:42 EST
Just checked in the wswb rollup - this problem still existed in the 1.0 refresh.
Comment 4 Randy Giffen CLA 2001-12-11 12:10:43 EST
This is a Core bug
We are calling the IProject.delete with the delete contents flag set to false.

The bug lies in the following method of Project.
Note that path.toFile().delete() is being called relying on the 
fact that it will not be deleted if it has contents.

However this is causing the OS level write protect error dialog to appear.
If I say ignore (WinNT - I get two dialogs), then the Project is successfully 
deleted from the workspace.  



/**
 * Deletes everything but contents. Needed for restore where we do not find
 * the .prj file. Also used from #delete.
 */
public void basicDelete(MultiStatus status) throws CoreException {
	// get the location first because it will be null after we delete the
	// project from the tree.
	IPath path = getLocation();
	deleteResource(false, status);
	// Delete the contents directory for the project. Note that this is a 
garbage
	// collection action only, and the directory will not get deleted if it 
still
	// contains files.
	if (path != null)
		path.toFile().delete();
	workspace.getMetaArea().delete(this);
	clearHistory(null);
}
Comment 5 John Arthorne CLA 2001-12-14 13:28:23 EST
I could not reproduce with the CD-ROM, but I received the following steps from 
Randy which reproduce the bug on Win2000:

1) Create a folder with a couple files on the floppy
2) Remove the floppy and move its tab to read-only
3) Replace the floppy and create a project targeted to the floppy folder.
4) Try to delete the project, say "No" to delete content.

You get an OS dialog saying the disk is write-protected.  This doesn't make 
sense to the user because he said not to delete content.

Comment 6 John Arthorne CLA 2002-01-03 13:51:38 EST
Fixed, tested and released.  Fix was to remove the call to delete() from the 
basicDelete method.  It was only a cleanup operation to remove the directory if 
empty.  It is more appropriate to just leave the empty directory if the caller 
has specified not to delete contents.