mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-06 15:55:47 +02:00
[285942] Throw exception when listing a non-folder
This commit is contained in:
parent
7b5ab90e48
commit
db3e6c68dd
4 changed files with 55 additions and 45 deletions
|
@ -584,7 +584,7 @@
|
||||||
<feature url="features/org.eclipse.rse.dstore_3.1.1.qualifier.jar" id="org.eclipse.rse.dstore" version="3.1.1.qualifier">
|
<feature url="features/org.eclipse.rse.dstore_3.1.1.qualifier.jar" id="org.eclipse.rse.dstore" version="3.1.1.qualifier">
|
||||||
<category name="TM and RSE 3.1.1"/>
|
<category name="TM and RSE 3.1.1"/>
|
||||||
</feature>
|
</feature>
|
||||||
<feature url="features/org.eclipse.rse.ftp_3.0.100.qualifier.jar" id="org.eclipse.rse.ftp" version="3.0.100.qualifier">
|
<feature url="features/org.eclipse.rse.ftp_3.0.101.qualifier.jar" id="org.eclipse.rse.ftp" version="3.0.101.qualifier">
|
||||||
<category name="TM and RSE 3.1.1"/>
|
<category name="TM and RSE 3.1.1"/>
|
||||||
</feature>
|
</feature>
|
||||||
<feature url="features/org.eclipse.rse.local_2.1.101.qualifier.jar" id="org.eclipse.rse.local" version="2.1.101.qualifier">
|
<feature url="features/org.eclipse.rse.local_2.1.101.qualifier.jar" id="org.eclipse.rse.local" version="2.1.101.qualifier">
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<feature
|
<feature
|
||||||
id="org.eclipse.rse.ftp"
|
id="org.eclipse.rse.ftp"
|
||||||
label="%featureName"
|
label="%featureName"
|
||||||
version="3.0.100.qualifier"
|
version="3.0.101.qualifier"
|
||||||
provider-name="%providerName"
|
provider-name="%providerName"
|
||||||
plugin="org.eclipse.rse.services.files.ftp">
|
plugin="org.eclipse.rse.services.files.ftp">
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.rse.services.files.ftp;singleton:=true
|
Bundle-SymbolicName: org.eclipse.rse.services.files.ftp;singleton:=true
|
||||||
Bundle-Version: 3.0.100.qualifier
|
Bundle-Version: 3.0.101.qualifier
|
||||||
Bundle-Activator: org.eclipse.rse.internal.services.files.ftp.Activator
|
Bundle-Activator: org.eclipse.rse.internal.services.files.ftp.Activator
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [240738][ftp] Incorrect behavior on getFile for non-existing folder
|
* Martin Oberhuber (Wind River) - [240738][ftp] Incorrect behavior on getFile for non-existing folder
|
||||||
* David McKnight (IBM) - [243921] FTP subsystem timeout causes error when expanding folders
|
* David McKnight (IBM) - [243921] FTP subsystem timeout causes error when expanding folders
|
||||||
* Martin Oberhuber (Wind River) - [217472][ftp] Error copying files with very short filenames
|
* Martin Oberhuber (Wind River) - [217472][ftp] Error copying files with very short filenames
|
||||||
|
* Martin Oberhuber (Wind River) - [285942] Throw exception when listing a non-folder
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.files.ftp;
|
package org.eclipse.rse.internal.services.files.ftp;
|
||||||
|
@ -127,6 +128,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundExcep
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException;
|
import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemNetworkIOException;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException;
|
import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemUnsupportedOperationException;
|
import org.eclipse.rse.services.clientserver.messages.SystemUnsupportedOperationException;
|
||||||
import org.eclipse.rse.services.files.AbstractFileService;
|
import org.eclipse.rse.services.files.AbstractFileService;
|
||||||
|
@ -358,6 +360,16 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SystemMessageException makeSystemMessageException(Exception e) {
|
||||||
|
if (e instanceof SystemMessageException) {
|
||||||
|
// dont wrap SystemMessageException again
|
||||||
|
return (SystemMessageException) e;
|
||||||
|
} else if (e instanceof IOException) {
|
||||||
|
return new SystemNetworkIOException(e);
|
||||||
|
}
|
||||||
|
return new RemoteFileIOException(e);
|
||||||
|
}
|
||||||
|
|
||||||
public void connect() throws RemoteFileSecurityException,IOException
|
public void connect() throws RemoteFileSecurityException,IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -496,6 +508,24 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void chdir(FTPClient ftpClient, String remoteFolder) throws SystemMessageException {
|
||||||
|
// try to retrieve the file
|
||||||
|
try {
|
||||||
|
if (!ftpClient.changeWorkingDirectory(remoteFolder)) {
|
||||||
|
String reply = ftpClient.getReplyString();
|
||||||
|
if (reply != null && reply.startsWith("550")) { //$NON-NLS-1$
|
||||||
|
if (!reply.trim().endsWith("Not a directory.")) { //$NON-NLS-1$
|
||||||
|
// No such file or directory
|
||||||
|
throw new SystemElementNotFoundException(remoteFolder, "chdir"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RemoteFileIOException(new Exception(reply + " (" + remoteFolder + ")")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SystemNetworkIOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the commons.net FTPClient for this session.
|
* Returns the commons.net FTPClient for this session.
|
||||||
*
|
*
|
||||||
|
@ -639,18 +669,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
try {
|
try {
|
||||||
//try to retrieve the file
|
//try to retrieve the file
|
||||||
_ftpClient = getFTPClient();
|
_ftpClient = getFTPClient();
|
||||||
|
chdir(_ftpClient, remoteParent);
|
||||||
if(!_ftpClient.changeWorkingDirectory(remoteParent))
|
|
||||||
{
|
|
||||||
String reply = _ftpClient.getReplyString();
|
|
||||||
if (reply != null && reply.startsWith("550")) { //$NON-NLS-1$
|
|
||||||
// No such file or directory
|
|
||||||
throw new SystemElementNotFoundException(remoteParent, "chdir"); //$NON-NLS-1$
|
|
||||||
} else {
|
|
||||||
throw new RemoteFileIOException(new Exception(reply));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!listFiles(monitor))
|
if(!listFiles(monitor))
|
||||||
{
|
{
|
||||||
throw new SystemOperationCancelledException();
|
throw new SystemOperationCancelledException();
|
||||||
|
@ -684,7 +703,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
// Return non-existing file
|
// Return non-existing file
|
||||||
file = new FTPHostFile(remoteParent, fileName, false, false, 0, 0, false);
|
file = new FTPHostFile(remoteParent, fileName, false, false, 0, 0, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RemoteFileIOException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
_commandMutex.release();
|
_commandMutex.release();
|
||||||
}
|
}
|
||||||
|
@ -749,11 +768,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
}
|
}
|
||||||
|
|
||||||
_ftpClient = getFTPClient();
|
_ftpClient = getFTPClient();
|
||||||
if(!_ftpClient.changeWorkingDirectory(parentPath))
|
chdir(_ftpClient, parentPath);
|
||||||
{
|
|
||||||
throw new RemoteFileIOException(new Exception(_ftpClient.getReplyString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!listFiles(monitor))
|
if(!listFiles(monitor))
|
||||||
{
|
{
|
||||||
throw new SystemOperationCancelledException();
|
throw new SystemOperationCancelledException();
|
||||||
|
@ -794,7 +809,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new RemoteFileIOException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
_commandMutex.release();
|
_commandMutex.release();
|
||||||
}
|
}
|
||||||
|
@ -900,7 +915,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
|
|
||||||
try{
|
try{
|
||||||
clearCache(remoteParent);
|
clearCache(remoteParent);
|
||||||
ftpClient.changeWorkingDirectory(remoteParent);
|
chdir(ftpClient, remoteParent);
|
||||||
setFileType(isBinary);
|
setFileType(isBinary);
|
||||||
|
|
||||||
input = new FileInputStream(localFile);
|
input = new FileInputStream(localFile);
|
||||||
|
@ -988,7 +1003,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
try{
|
try{
|
||||||
|
|
||||||
FTPClient ftpClient = getFTPClient();
|
FTPClient ftpClient = getFTPClient();
|
||||||
ftpClient.changeWorkingDirectory(remoteParent);
|
chdir(ftpClient, remoteParent);
|
||||||
setFileType(isBinary);
|
setFileType(isBinary);
|
||||||
|
|
||||||
input = ftpClient.retrieveFileStream(remoteFile);
|
input = ftpClient.retrieveFileStream(remoteFile);
|
||||||
|
@ -1149,7 +1164,11 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
{
|
{
|
||||||
String newParentPath = concat(parentPath,fileName);
|
String newParentPath = concat(parentPath,fileName);
|
||||||
|
|
||||||
ftpClient.changeWorkingDirectory(newParentPath);
|
try {
|
||||||
|
chdir(ftpClient, newParentPath);
|
||||||
|
} catch (SystemElementNotFoundException e) {
|
||||||
|
/* nothing to do since dir does not exist */
|
||||||
|
}
|
||||||
FTPFile[] fileNames = ftpClient.listFiles();
|
FTPFile[] fileNames = ftpClient.listFiles();
|
||||||
|
|
||||||
for (int i = 0; i < fileNames.length; i++) {
|
for (int i = 0; i < fileNames.length; i++) {
|
||||||
|
@ -1161,7 +1180,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove empty folder
|
//remove empty folder
|
||||||
ftpClient.changeWorkingDirectory(parentPath);
|
chdir(ftpClient, parentPath);
|
||||||
hasSucceeded = ftpClient.removeDirectory(fileName);
|
hasSucceeded = ftpClient.removeDirectory(fileName);
|
||||||
if (!hasSucceeded)
|
if (!hasSucceeded)
|
||||||
{
|
{
|
||||||
|
@ -1185,12 +1204,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
try {
|
try {
|
||||||
FTPClient ftpClient = getFTPClient();
|
FTPClient ftpClient = getFTPClient();
|
||||||
clearCache(remoteParent);
|
clearCache(remoteParent);
|
||||||
|
chdir(ftpClient, remoteParent);
|
||||||
if(!ftpClient.changeWorkingDirectory(remoteParent))
|
|
||||||
{
|
|
||||||
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean success = ftpClient.rename(oldName, newName);
|
boolean success = ftpClient.rename(oldName, newName);
|
||||||
|
|
||||||
if(!success)
|
if(!success)
|
||||||
|
@ -1199,7 +1213,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RemoteFileIOException(e);
|
throw makeSystemMessageException(e);
|
||||||
}finally {
|
}finally {
|
||||||
_commandMutex.release();
|
_commandMutex.release();
|
||||||
}
|
}
|
||||||
|
@ -1264,11 +1278,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
{
|
{
|
||||||
FTPClient ftpClient = getFTPClient();
|
FTPClient ftpClient = getFTPClient();
|
||||||
clearCache(remoteParent);
|
clearCache(remoteParent);
|
||||||
if(!ftpClient.changeWorkingDirectory(remoteParent))
|
chdir(ftpClient, remoteParent);
|
||||||
{
|
|
||||||
throw new Exception(ftpClient.getReplyString()+" ("+remoteParent+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ftpClient.makeDirectory(folderName))
|
if(!ftpClient.makeDirectory(folderName))
|
||||||
{
|
{
|
||||||
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()+" ("+folderName+")")); //$NON-NLS-1$ //$NON-NLS-2$
|
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()+" ("+folderName+")")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -1276,7 +1286,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
throw new RemoteFileSecurityException(e);
|
throw makeSystemMessageException(e);
|
||||||
}finally {
|
}finally {
|
||||||
_commandMutex.release();
|
_commandMutex.release();
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1377,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
String newSrcParentPath = concat(srcParent,srcName);
|
String newSrcParentPath = concat(srcParent,srcName);
|
||||||
String newTgtParentPath = concat(tgtParent,tgtName);
|
String newTgtParentPath = concat(tgtParent,tgtName);
|
||||||
|
|
||||||
ftpClient.changeWorkingDirectory(newSrcParentPath);
|
chdir(ftpClient, newSrcParentPath);
|
||||||
FTPFile[] fileNames = ftpClient.listFiles();
|
FTPFile[] fileNames = ftpClient.listFiles();
|
||||||
|
|
||||||
for (int i = 0; i < fileNames.length; i++) {
|
for (int i = 0; i < fileNames.length; i++) {
|
||||||
|
@ -1385,7 +1395,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
File tempFile = null;
|
File tempFile = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tempFile = File.createTempFile("ftpcp" + String.valueOf(srcParent.hashCode()), "temp");
|
tempFile = File.createTempFile("ftpcp" + String.valueOf(srcParent.hashCode()), "temp"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RemoteFileIOException(e);
|
throw new RemoteFileIOException(e);
|
||||||
|
@ -1655,11 +1665,11 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FTPClient ftpClient = cloneFTPClient(isBinary);
|
FTPClient ftpClient = cloneFTPClient(isBinary);
|
||||||
ftpClient.changeWorkingDirectory(remoteParent);
|
chdir(ftpClient, remoteParent);
|
||||||
stream = new FTPBufferedInputStream(ftpClient.retrieveFileStream(remoteFile), ftpClient);
|
stream = new FTPBufferedInputStream(ftpClient.retrieveFileStream(remoteFile), ftpClient);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
throw new RemoteFileIOException(e);
|
throw makeSystemMessageException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
|
@ -1692,7 +1702,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false;
|
boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false;
|
||||||
FTPClient ftpClient = cloneFTPClient(isBinary);
|
FTPClient ftpClient = cloneFTPClient(isBinary);
|
||||||
clearCache(remoteParent);
|
clearCache(remoteParent);
|
||||||
ftpClient.changeWorkingDirectory(remoteParent);
|
chdir(ftpClient, remoteParent);
|
||||||
if ((options & IFileService.APPEND) == 0){
|
if ((options & IFileService.APPEND) == 0){
|
||||||
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
|
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1700,7 +1710,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
throw new RemoteFileIOException(e);
|
throw makeSystemMessageException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
|
|
Loading…
Add table
Reference in a new issue