diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java
index 26ef301bbf2..f0e1333b799 100644
--- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java
+++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java
@@ -1351,7 +1351,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
}
- public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
+ public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{
String remotePath = remoteParent + getSeparator(remoteParent) + fileName;
DataElement de = getElementFor(remotePath);
@@ -1374,7 +1374,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// When running a server older than 2.0.1 success is not set for directories, so we must
// check if the source message is an empty string
if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$
- return;
+ return true;
}
String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java
index 3243a1523a2..2ffadc7ca46 100644
--- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java
+++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java
@@ -1024,7 +1024,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
/* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#delete(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String)
*/
- public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
+ public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
remoteParent = checkEncoding(remoteParent);
fileName = checkEncoding(fileName);
@@ -1035,13 +1035,22 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
if (_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) {
try {
+ //Try to delete even if it looked like the file doesn't exist,
+ //since existence might have been cached and be out-of-date
FTPClient ftpClient = getFTPClient();
internalDelete(ftpClient, remoteParent, fileName, file.isFile(), progressMonitor);
}
catch (IOException e)
{
+ if (!file.exists())
+ return false;
throw new RemoteFileIOException(e);
}
+ catch (SystemMessageException e) {
+ if (!file.exists())
+ return false;
+ throw e;
+ }
finally {
_commandMutex.release();
}
@@ -1051,6 +1060,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} finally {
progressMonitor.end();
}
+ return true;
}
private void internalDelete(FTPClient ftpClient, String parentPath, String fileName, boolean isFile, MyProgressMonitor monitor)
diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java
index cfc6a48b39f..79537e56abe 100644
--- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java
+++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java
@@ -1015,7 +1015,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return new LocalVirtualHostFile(child);
}
- public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
+ public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{
if (fileName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR))
{
@@ -1026,23 +1026,30 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
{
remoteParent = remoteParent + ArchiveHandlerManager.VIRTUAL_SEPARATOR;
}
+ boolean result = true;
File fileToDelete = new File(remoteParent, fileName);
if (ArchiveHandlerManager.isVirtual(fileToDelete.getAbsolutePath()))
{
- deleteFromArchive(fileToDelete, monitor);
+ result = deleteFromArchive(fileToDelete, monitor);
}
else if (ArchiveHandlerManager.getInstance().isArchive(fileToDelete))
{
- deleteArchive(fileToDelete);
+ result = deleteArchive(fileToDelete);
}
if (fileToDelete.isDirectory())
{
- deleteContents(fileToDelete, monitor);
+ result = deleteContents(fileToDelete, monitor);
}
else
{
- fileToDelete.delete();
+ result = fileToDelete.delete();
}
+ if (!result && fileToDelete.exists()) {
+ // Deletion failed without specification why... likely a Security
+ // problem?
+ throw new RemoteFileSecurityException(null);
+ }
+ return result;
}
public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException
@@ -1099,9 +1106,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor);
checkArchiveOperationStatusThread.start();
}
- boolean returnValue = handler.delete(child.fullName, archiveOperationMonitor);
- if (!returnValue)
- {
+ try {
+ return handler.delete(child.fullName, archiveOperationMonitor);
+ } catch (SystemMessageException e) {
if (monitor != null && monitor.isCanceled())
{
//This operation has been cancelled by the user.
@@ -1109,12 +1116,12 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
}
// SystemPlugin.logError("LocalFileSubSystemImpl.deleteFromArchive(): Archive Handler's delete method returned false. Couldn't delete virtual object.");
String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_DELETE_VIRTUAL_FAILED, destination);
- String msgDetails = LocalServiceResources.FILEMSG_DELETE_VIRTUAL_FAILED_DETAILS;
+ //String msgDetails = LocalServiceResources.FILEMSG_DELETE_VIRTUAL_FAILED_DETAILS;
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_DELETE_VIRTUAL_FAILED,
- IStatus.ERROR, msgTxt, msgDetails));
+ IStatus.ERROR,
+ msgTxt, e));
}
- return true;
}
protected boolean deleteArchive(File file)
diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java
index 20fbc7c8f5d..1b9334366f9 100644
--- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java
+++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java
@@ -891,7 +891,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
return result;
}
- public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
+ public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{
String fullPath = concat(remoteParent, fileName);
Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$
@@ -912,6 +912,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
}
if (attrs==null) {
//doesn't exist, nothing to do
+ return false;
} else if (attrs.isDir()) {
try {
getChannel("SftpFileService.delete.rmdir").rmdir(fullPathRecoded); //$NON-NLS-1$
@@ -941,6 +942,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
} else {
throw new SystemLockTimeoutException(Activator.PLUGIN_ID);
}
+ return true;
}
public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java
index 7b74d646fcb..ebcbf3db85f 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java
@@ -406,16 +406,19 @@ public interface IFileService extends IService
/**
* Delete a file or folder on the host.
- *
+ *
* @param remoteParent the folder containing the file to delete
* @param fileName the name of the file or folder to delete
* @param monitor the progress monitor
- * @throws SystemMessageException if an error occurs. Typically this would
- * be one of those in the RemoteFileException family.
- *
+ * @return true
if the requested element was successfully
+ * deleted, or false
if the element had not existed in the
+ * first place so the operation was a silent no-op.
+ * @throws SystemMessageException if an error occurs or the user canceled
+ * the operation.
+ *
* @since org.eclipse.rse.services 3.0
*/
- public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException;
+ public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Delete a set of files or folders on the host. Should throw an exception
diff --git a/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java b/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java
index 0b8f6029074..46affee7c80 100644
--- a/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java
+++ b/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java
@@ -189,14 +189,14 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
}
}
- public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
+ public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
String fullPath = concat(remoteParent, fileName);
IRapiSession session = sessionProvider.getSession();
try {
if (isDirectory(session, fullPath)) {
// recursive delete if it is a directory
RapiFindData[] allFiles = session.findAllFiles(concat(fullPath, "*"), Rapi.FAF_NAME); //$NON-NLS-1$
- for (int i = 0 ; i < allFiles.length ; i++) {
+ for (int i = 0; i < allFiles.length; i++) {
delete(fullPath, allFiles[i].fileName, monitor);
}
session.removeDirectory(fullPath);
@@ -208,6 +208,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
//FIXME error handling
throw new RemoteFileException(e.getMessage(), e);
}
+ return true;
}
public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding,