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

Bug 27187

Summary: [Navigator] Need to avoid delete before overwriting file
Product: [Eclipse Project] Platform Reporter: Nick Edgar <n.a.edgar>
Component: UIAssignee: Knut Radloff <knut_radloff>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: jed.anderson
Version: 2.1   
Target Milestone: 2.1 M4   
Hardware: All   
OS: All   
Whiteboard:

Description Nick Edgar CLA 2002-11-26 16:05:07 EST
build I20021119

Bug 20036 describes several areas in the UI where we delete a file if it 
exists at the destination of a copy, move or import.
These should all be fixed to use validateEdit then setContents, or 
validateEdit then copy/move (requires new Core API to allow overwrite in these 
cases -- see bug 27184).

We need to fix at least the following cases.  There may be more.
- import from file system
- copy resource
- move resource
- paste from file system
- drag-and-drop from file system

See bug 20036 for the details on how to handle validateEdit properly.
Basically we need to batch as many files as we can in the validateEdit call, 
to provide the highest granularity of atomicity to the operation.
E.g. if I'm copying over 3 files, and one of them can't be checked out because 
some other developer has it checked out, you don't want the other 2 to be 
overwritten.
Comment 1 Nick Edgar CLA 2002-11-26 16:08:04 EST
Sorry, the details are in bug 21666.

This is needed for 2.1 M4.
We should fix the cases we can while waiting for the new copy/move Core APIs: 
change any occurrences of delete/create to validateEdit/setContents.
Comment 2 Knut Radloff CLA 2002-11-27 12:02:28 EST
It seems that the there is no agreement yet on adding OVERWRITE flag for 
copy/move vs. using setContents. Discussed in bug 27184.
Comment 3 Knut Radloff CLA 2002-11-27 12:05:07 EST
*** Bug 21666 has been marked as a duplicate of this bug. ***
Comment 4 Nick Edgar CLA 2002-11-27 16:13:40 EST
Basically the semantics of copy in the case of overwrite are really unclear.
Even in the non-overwrite case, the semantics are somewhat funny in that it 
copies persistent properties, but not session properties or markers.
Until these issues are sorted out, the safer option is to just use setContents.
This will at least not wipe out any persistent properties already on the dest.
If the user really wants persistent properties copied from the source to 
replace those on the dest, they can manually delete the dest then copy.
Comment 5 Knut Radloff CLA 2002-12-12 19:52:26 EST
Fixed copy/move resource case with the following assumptions:
1. deleting the source after a move/setContents does not need to call 
validateEdit
2. an ERROR result from IWorkspace.validateEdit means the file validation was 
cancelled or the files could not be made read/write.
3. when passing multiple files to validateEdit and some files were rejected 
while others were made read/write the return status is a multi status. Further, 
The order of the status children must match that of the files that were passed 
in. See bug 28216 for details.
Comment 6 Knut Radloff CLA 2002-12-13 17:53:38 EST
Fixed import cases (using wizard, paste, drag and drop). 
Changed ImportOperation to prompt for overwrite and validateEdit before 
starting the import. Added ImportOperation.setContext API to set a context for 
the validateEdit call.
Comment 7 Knut Radloff CLA 2002-12-13 20:32:13 EST
The behavior when deselecting all verified files in the prompting dialog is 
unexpected. The return status is the same as when pressing cancel. This means 
that when importing multiple files the operation will be cancelled if all 
validated files are deselected. Files that don't need to be validated will also 
be cancelled which is wrong. See bug 28313.
Comment 8 Knut Radloff CLA 2002-12-17 10:16:53 EST
Open issues are sufficiently captured in other PRs. Deleting the source after a 
move setContents is captured in bug 21666.
Fixed in 20021216.