mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Use authority section when converting a UNC path to a URI so that the
connection name is correctly escaped. Attempt to open connection before performing any EFS operations. Change-Id: I1f60b70873e411ba37a2115072df09828fdf4c27 Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
b3dbbaca76
commit
fcaf58a291
2 changed files with 20 additions and 17 deletions
|
@ -143,7 +143,7 @@ public class RemoteServicesUtils {
|
||||||
String scheme = conn.getRemoteServices().getScheme();
|
String scheme = conn.getRemoteServices().getScheme();
|
||||||
String filePath = path.removeFirstSegments(1).makeAbsolute().toString();
|
String filePath = path.removeFirstSegments(1).makeAbsolute().toString();
|
||||||
try {
|
try {
|
||||||
return new URI(scheme, connName, filePath, null);
|
return new URI(scheme, connName, filePath, null, null);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class JschFileStore extends FileStore {
|
||||||
fRemotePath = new Path(uri.getPath());
|
fRemotePath = new Path(uri.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSchConnection checkConnection() throws RemoteConnectionException {
|
private JSchConnection checkConnection(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||||
IRemoteServices services = RemoteServices.getRemoteServices(fURI);
|
IRemoteServices services = RemoteServices.getRemoteServices(fURI);
|
||||||
assert (services instanceof JSchServices);
|
assert (services instanceof JSchServices);
|
||||||
if (services == null) {
|
if (services == null) {
|
||||||
|
@ -85,7 +85,10 @@ public class JschFileStore extends FileStore {
|
||||||
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_Invalid_connection_for_URI, fURI));
|
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_Invalid_connection_for_URI, fURI));
|
||||||
}
|
}
|
||||||
if (!connection.isOpen()) {
|
if (!connection.isOpen()) {
|
||||||
throw new RemoteConnectionException(Messages.JschFileStore_Connection_is_not_open);
|
connection.open(monitor);
|
||||||
|
if (!connection.isOpen()) {
|
||||||
|
throw new RemoteConnectionException(Messages.JschFileStore_Connection_is_not_open);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (JSchConnection) connection;
|
return (JSchConnection) connection;
|
||||||
}
|
}
|
||||||
|
@ -98,10 +101,10 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
|
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
||||||
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
ChildInfosCommand command = new ChildInfosCommand(connection, fRemotePath);
|
ChildInfosCommand command = new ChildInfosCommand(connection, fRemotePath);
|
||||||
return command.getResult(subMon.newChild(10));
|
return command.getResult(subMon.newChild(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -129,9 +132,9 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete(int options, IProgressMonitor monitor) throws CoreException {
|
public void delete(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 20);
|
SubMonitor subMon = SubMonitor.convert(monitor, 20);
|
||||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
|
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
||||||
if (!subMon.isCanceled() && info.exists()) {
|
if (!subMon.isCanceled() && info.exists()) {
|
||||||
DeleteCommand command = new DeleteCommand(connection, fRemotePath);
|
DeleteCommand command = new DeleteCommand(connection, fRemotePath);
|
||||||
command.getResult(subMon.newChild(10));
|
command.getResult(subMon.newChild(10));
|
||||||
|
@ -146,10 +149,10 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
|
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
||||||
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
FetchInfoCommand command = new FetchInfoCommand(connection, fRemotePath);
|
FetchInfoCommand command = new FetchInfoCommand(connection, fRemotePath);
|
||||||
return command.getResult(subMon.newChild(10));
|
return command.getResult(subMon.newChild(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -213,12 +216,12 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
|
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 20);
|
SubMonitor subMon = SubMonitor.convert(monitor, 20);
|
||||||
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
|
|
||||||
if ((options & EFS.SHALLOW) == EFS.SHALLOW) {
|
if ((options & EFS.SHALLOW) == EFS.SHALLOW) {
|
||||||
IFileStore parent = getParent();
|
IFileStore parent = getParent();
|
||||||
if (parent != null && !parent.fetchInfo(EFS.NONE, subMon.newChild(10)).exists()) {
|
if (parent != null && !parent.fetchInfo(EFS.NONE, subMon.newChild(9)).exists()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
|
||||||
Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
|
Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
|
||||||
}
|
}
|
||||||
|
@ -261,9 +264,9 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
|
public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 30);
|
SubMonitor subMon = SubMonitor.convert(monitor, 30);
|
||||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
|
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
||||||
if (!subMon.isCanceled()) {
|
if (!subMon.isCanceled()) {
|
||||||
if (!info.exists()) {
|
if (!info.exists()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_READ, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_READ, NLS.bind(
|
||||||
|
@ -287,9 +290,9 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
|
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 30);
|
SubMonitor subMon = SubMonitor.convert(monitor, 30);
|
||||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
|
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
||||||
if (!subMon.isCanceled()) {
|
if (!subMon.isCanceled()) {
|
||||||
if (info.isDirectory()) {
|
if (info.isDirectory()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
|
||||||
|
@ -310,10 +313,10 @@ public class JschFileStore extends FileStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
|
public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
|
||||||
JSchConnection connection = checkConnection();
|
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
||||||
|
JSchConnection connection = checkConnection(subMon.newChild(1));
|
||||||
PutInfoCommand command = new PutInfoCommand(connection, info, options, fRemotePath);
|
PutInfoCommand command = new PutInfoCommand(connection, info, options, fRemotePath);
|
||||||
command.getResult(subMon.newChild(10));
|
command.getResult(subMon.newChild(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue