1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 03:53:21 +02:00

Bug 163565: Multiple files are not deleted when one of them fails to be deleted

This commit is contained in:
Kushal Munir 2006-11-09 13:37:23 +00:00
parent 2823aeb890
commit 810b8008ba
5 changed files with 27 additions and 3 deletions

View file

@ -184,7 +184,9 @@ public interface IFileService extends IService
public boolean delete(IProgressMonitor monitor, String remoteParent, String fileName) throws SystemMessageException;
/**
* Deletes a set of files or folders on the host
* Deletes a set of files or folders on the host. Should throw an exception if some files and folders were deleted and others were not
* due to an exception during the operation. Without an exception thrown in such cases, views may not be refreshed correctly to account
* for deleted resources.
* @param monitor the progress monitor
* @param remoteParents the array of folders containing the files to delete
* @param fileNames the names of the files or folders to delete

View file

@ -313,7 +313,8 @@ public interface IRemoteFileSubSystem extends ISubSystem{
* <ul>
* <li>If any of the inputs are a folder, those folders must be empty for this to succeed.
* </ul>
*
* Should throw an exception if some files and folders were deleted and others were not due to an exception during the operation.
* Without an exception thrown in such cases, views may not be refreshed correctly to account for deleted resources.
* @param folderOrFiles represents the objects to be deleted.
* @param monitor progressMonitor
* @return false if any of the given folder/file dont exist to begin with, else true. Throws an exception if anything fails.

View file

@ -4337,6 +4337,8 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour
boolean ok = true;
boolean anyOk = false;
Vector deletedVector = new Vector();
// keep track of the current set
SystemRemoteElementResourceSet set = null;
try {
@ -4359,7 +4361,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour
ISystemViewElementAdapter srcAdapter = set.getAdapter();
if (srcSubSystem != null) {
// this call can throw an exception
ok = srcAdapter.doDeleteBatch(getShell(), set.getResourceSet(), monitor);
if (ok) {
anyOk = true;
deletedVector.addAll(set.getResourceSet());
@ -4377,6 +4382,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour
// refresh all parents if selection is remote objects
if (selectionIsRemoteObject) {
// we only need to iterate over the last set in the list of sets since presumably the sets before did not cause any exceptions
// if elements in the list before were deleted successfully, then the code after this catch block will handle them (by firing delete events)
// for the current set that caused the exception, we refresh the parents of the elements in the set (since we don't know which
// elements in the set may have been deleted successfully before the exception occurred).
if (set != null) {
List list = set.getResourceSet();

View file

@ -235,7 +235,10 @@ public interface ISystemViewElementAdapter extends IPropertySource, ISystemDragD
throws Exception;
/**
* Perform the delete on the given set of items. This is after the user has been asked to confirm deletion.
* Perform the delete on the given set of items. This is after the user has been asked to confirm deletion. Should throw an exception
* if some elements were deleted and others were not due to an exception during the operation. Without an exception
* thrown in such cases, views may not be refreshed correctly to account for deleted resources.
* @return <code>true</code> if the delete was successful, <code>false</code> if it was not.
*/
public boolean doDeleteBatch(Shell shell, List resourceSet, IProgressMonitor monitor)
throws Exception;

View file

@ -4337,6 +4337,8 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour
boolean ok = true;
boolean anyOk = false;
Vector deletedVector = new Vector();
// keep track of the current set
SystemRemoteElementResourceSet set = null;
try {
@ -4359,7 +4361,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour
ISystemViewElementAdapter srcAdapter = set.getAdapter();
if (srcSubSystem != null) {
// this call can throw an exception
ok = srcAdapter.doDeleteBatch(getShell(), set.getResourceSet(), monitor);
if (ok) {
anyOk = true;
deletedVector.addAll(set.getResourceSet());
@ -4377,6 +4382,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour
// refresh all parents if selection is remote objects
if (selectionIsRemoteObject) {
// we only need to iterate over the last set in the list of sets since presumably the sets before did not cause any exceptions
// if elements in the list before were deleted successfully, then the code after this catch block will handle them (by firing delete events)
// for the current set that caused the exception, we refresh the parents of the elements in the set (since we don't know which
// elements in the set may have been deleted successfully before the exception occurred).
if (set != null) {
List list = set.getResourceSet();