mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
Improve error reporting for Ssh-sftp (add full paths to tracing exceptions)
This commit is contained in:
parent
0fbab59e21
commit
00fc6f2873
1 changed files with 46 additions and 50 deletions
|
@ -400,9 +400,9 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
//the API docs.
|
//the API docs.
|
||||||
SftpHostFile node = null;
|
SftpHostFile node = null;
|
||||||
SftpATTRS attrs = null;
|
SftpATTRS attrs = null;
|
||||||
|
String fullPath = concat(remoteParent, fileName);
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String fullPath = concat(remoteParent, fileName);
|
|
||||||
attrs = getChannel("SftpFileService.getFile: "+fullPath).stat(recodeSafe(fullPath)); //$NON-NLS-1$
|
attrs = getChannel("SftpFileService.getFile: "+fullPath).stat(recodeSafe(fullPath)); //$NON-NLS-1$
|
||||||
Activator.trace("SftpFileService.getFile <--"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.getFile <--"); //$NON-NLS-1$
|
||||||
node = makeHostFile(remoteParent, fileName, attrs);
|
node = makeHostFile(remoteParent, fileName, attrs);
|
||||||
|
@ -552,6 +552,10 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
|
|
||||||
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
|
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
|
String dst = remoteParent;
|
||||||
|
if( remoteFile!=null ) {
|
||||||
|
dst = concat(dst, remoteFile);
|
||||||
|
}
|
||||||
//TODO what to do with isBinary?
|
//TODO what to do with isBinary?
|
||||||
ChannelSftp channel = null;
|
ChannelSftp channel = null;
|
||||||
//Fixing bug 158534. TODO remove when bug 162688 is fixed.
|
//Fixing bug 158534. TODO remove when bug 162688 is fixed.
|
||||||
|
@ -561,13 +565,6 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
try {
|
try {
|
||||||
SftpProgressMonitor sftpMonitor=new MyProgressMonitor(monitor);
|
SftpProgressMonitor sftpMonitor=new MyProgressMonitor(monitor);
|
||||||
int mode=ChannelSftp.OVERWRITE;
|
int mode=ChannelSftp.OVERWRITE;
|
||||||
String dst = remoteParent;
|
|
||||||
if( remoteFile!=null ) {
|
|
||||||
if (!dst.endsWith("/")) { //$NON-NLS-1$
|
|
||||||
dst += '/';
|
|
||||||
}
|
|
||||||
dst += remoteFile;
|
|
||||||
}
|
|
||||||
dst = recodeSafe(dst);
|
dst = recodeSafe(dst);
|
||||||
getChannel("SftpFileService.upload "+remoteFile); //check the session is healthy //$NON-NLS-1$
|
getChannel("SftpFileService.upload "+remoteFile); //check the session is healthy //$NON-NLS-1$
|
||||||
channel=(ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
channel=(ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
||||||
|
@ -593,7 +590,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.upload "+remoteFile+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.upload "+dst+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
//return false;
|
//return false;
|
||||||
}
|
}
|
||||||
|
@ -671,6 +668,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
|
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
ChannelSftp channel = null;
|
ChannelSftp channel = null;
|
||||||
|
String remotePath = concat(remoteParent, remoteFile);
|
||||||
try {
|
try {
|
||||||
if (!localFile.exists()) {
|
if (!localFile.exists()) {
|
||||||
File localParentFile = localFile.getParentFile();
|
File localParentFile = localFile.getParentFile();
|
||||||
|
@ -680,18 +678,18 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
//localFile.createNewFile();
|
//localFile.createNewFile();
|
||||||
}
|
}
|
||||||
//TODO Ascii/binary?
|
//TODO Ascii/binary?
|
||||||
String remotePath = recode(concat(remoteParent, remoteFile));
|
String remotePathRecoded = recode(remotePath);
|
||||||
int mode=ChannelSftp.OVERWRITE;
|
int mode=ChannelSftp.OVERWRITE;
|
||||||
MyProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
|
MyProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
|
||||||
getChannel("SftpFileService.download "+remoteFile); //check the session is healthy //$NON-NLS-1$
|
getChannel("SftpFileService.download "+remoteFile); //check the session is healthy //$NON-NLS-1$
|
||||||
channel=(ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
channel=(ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
||||||
channel.connect();
|
channel.connect();
|
||||||
channel.get(remotePath, localFile.getAbsolutePath(), sftpMonitor, mode);
|
channel.get(remotePathRecoded, localFile.getAbsolutePath(), sftpMonitor, mode);
|
||||||
Activator.trace("SftpFileService.download "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.download "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
SftpATTRS attr = channel.stat(remotePath);
|
SftpATTRS attr = channel.stat(remotePathRecoded);
|
||||||
localFile.setLastModified(1000L * attr.getMTime());
|
localFile.setLastModified(1000L * attr.getMTime());
|
||||||
//TODO should we set the read-only status?
|
//TODO should we set the read-only status?
|
||||||
//if (0==(attrs.getPermissions() & 00400)) localFile.setReadOnly();
|
//if (0==(attrs.getPermissions() & 00400)) localFile.setReadOnly();
|
||||||
|
@ -705,7 +703,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
//TODO improve message and handling when trying to download a symlink
|
//TODO improve message and handling when trying to download a symlink
|
||||||
Activator.trace("SftpFileService.download "+remoteFile+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.download "+remotePath+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
//Note: In case of an exception, the caller needs to ensure that in case
|
//Note: In case of an exception, the caller needs to ensure that in case
|
||||||
//we downloaded to a temp file, the temp file is deleted again, or a
|
//we downloaded to a temp file, the temp file is deleted again, or a
|
||||||
|
@ -749,19 +747,20 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
public IHostFile createFile(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
public IHostFile createFile(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
IHostFile result = null;
|
IHostFile result = null;
|
||||||
|
String fullPath = concat(remoteParent, fileName);
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String fullPath = recodeSafe(concat(remoteParent, fileName));
|
String fullPathRecoded = recodeSafe(concat(remoteParent, fileName));
|
||||||
OutputStream os = getChannel("SftpFileService.createFile").put(fullPath); //$NON-NLS-1$
|
OutputStream os = getChannel("SftpFileService.createFile").put(fullPathRecoded); //$NON-NLS-1$
|
||||||
//TODO workaround bug 153118: write a single space
|
//TODO workaround bug 153118: write a single space
|
||||||
//since jsch hangs when trying to close the stream without writing
|
//since jsch hangs when trying to close the stream without writing
|
||||||
os.write(32);
|
os.write(32);
|
||||||
os.close();
|
os.close();
|
||||||
SftpATTRS attrs = getChannel("SftpFileService.createFile.stat").stat(fullPath); //$NON-NLS-1$
|
SftpATTRS attrs = getChannel("SftpFileService.createFile.stat").stat(fullPathRecoded); //$NON-NLS-1$
|
||||||
result = makeHostFile(remoteParent, fileName, attrs);
|
result = makeHostFile(remoteParent, fileName, attrs);
|
||||||
Activator.trace("SftpFileService.createFile ok"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.createFile ok"); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.createFile failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.createFile "+fullPath+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
fDirChannelMutex.release();
|
fDirChannelMutex.release();
|
||||||
|
@ -775,15 +774,16 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
public IHostFile createFolder(String remoteParent, String folderName, IProgressMonitor monitor) throws SystemMessageException
|
public IHostFile createFolder(String remoteParent, String folderName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
IHostFile result = null;
|
IHostFile result = null;
|
||||||
|
String fullPath = concat(remoteParent, folderName);
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String fullPath = recodeSafe(concat(remoteParent, folderName));
|
String fullPathRecoded = recodeSafe(fullPath);
|
||||||
getChannel("SftpFileService.createFolder").mkdir(fullPath); //$NON-NLS-1$
|
getChannel("SftpFileService.createFolder").mkdir(fullPathRecoded); //$NON-NLS-1$
|
||||||
SftpATTRS attrs = getChannel("SftpFileService.createFolder.stat").stat(fullPath); //$NON-NLS-1$
|
SftpATTRS attrs = getChannel("SftpFileService.createFolder.stat").stat(fullPathRecoded); //$NON-NLS-1$
|
||||||
result = makeHostFile(remoteParent, folderName, attrs);
|
result = makeHostFile(remoteParent, folderName, attrs);
|
||||||
Activator.trace("SftpFileService.createFolder ok"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.createFolder ok"); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.createFolder failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.createFolder "+fullPath+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
fDirChannelMutex.release();
|
fDirChannelMutex.release();
|
||||||
|
@ -797,18 +797,19 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
boolean ok=false;
|
boolean ok=false;
|
||||||
|
String fullPath = concat(remoteParent, fileName);
|
||||||
Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String fullPath = recodeSafe(concat(remoteParent, fileName));
|
String fullPathRecoded = recodeSafe(fullPath);
|
||||||
SftpATTRS attrs = null;
|
SftpATTRS attrs = null;
|
||||||
try {
|
try {
|
||||||
attrs = getChannel("SftpFileService.delete").lstat(fullPath); //$NON-NLS-1$
|
attrs = getChannel("SftpFileService.delete").lstat(fullPathRecoded); //$NON-NLS-1$
|
||||||
} catch (SftpException e) {
|
} catch (SftpException e) {
|
||||||
//bug 154419: test for dangling symbolic link
|
//bug 154419: test for dangling symbolic link
|
||||||
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
|
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
|
||||||
//simply try to delete --> if it really doesnt exist, this will throw an exception
|
//simply try to delete --> if it really doesnt exist, this will throw an exception
|
||||||
getChannel("SftpFileService.delete.rm").rm(fullPath); //$NON-NLS-1$
|
getChannel("SftpFileService.delete.rm").rm(fullPathRecoded); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -818,13 +819,13 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
ok=true;
|
ok=true;
|
||||||
} else if (attrs.isDir()) {
|
} else if (attrs.isDir()) {
|
||||||
try {
|
try {
|
||||||
getChannel("SftpFileService.delete.rmdir").rmdir(fullPath); //$NON-NLS-1$
|
getChannel("SftpFileService.delete.rmdir").rmdir(fullPathRecoded); //$NON-NLS-1$
|
||||||
ok=true;
|
ok=true;
|
||||||
} catch(SftpException e) {
|
} catch(SftpException e) {
|
||||||
if(e.id==ChannelSftp.SSH_FX_FAILURE) {
|
if(e.id==ChannelSftp.SSH_FX_FAILURE) {
|
||||||
//Bug 153649: Recursive directory delete
|
//Bug 153649: Recursive directory delete
|
||||||
//throw new RemoteFolderNotEmptyException();
|
//throw new RemoteFolderNotEmptyException();
|
||||||
String fullPathQuoted = PathUtility.enQuoteUnix(fullPath);
|
String fullPathQuoted = PathUtility.enQuoteUnix(fullPathRecoded);
|
||||||
int rv = runCommand("rm -rf "+fullPathQuoted, monitor); //$NON-NLS-1$
|
int rv = runCommand("rm -rf "+fullPathQuoted, monitor); //$NON-NLS-1$
|
||||||
ok = (rv==0);
|
ok = (rv==0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -832,12 +833,12 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getChannel("SftpFileService.delete.rm").rm(fullPath); //$NON-NLS-1$
|
getChannel("SftpFileService.delete.rm").rm(fullPathRecoded); //$NON-NLS-1$
|
||||||
ok=true;
|
ok=true;
|
||||||
}
|
}
|
||||||
Activator.trace("SftpFileService.delete ok"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.delete ok"); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.delete: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.delete "+fullPath+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
fDirChannelMutex.release();
|
fDirChannelMutex.release();
|
||||||
|
@ -849,15 +850,15 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
|
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
boolean ok=false;
|
boolean ok=false;
|
||||||
|
String fullPathOld = concat(remoteParent, oldName);
|
||||||
|
String fullPathNew = concat(remoteParent, newName);
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String fullPathOld = concat(remoteParent, oldName);
|
|
||||||
String fullPathNew = concat(remoteParent, newName);
|
|
||||||
getChannel("SftpFileService.rename").rename(recode(fullPathOld), recodeSafe(fullPathNew)); //$NON-NLS-1$
|
getChannel("SftpFileService.rename").rename(recode(fullPathOld), recodeSafe(fullPathNew)); //$NON-NLS-1$
|
||||||
ok=true;
|
ok=true;
|
||||||
Activator.trace("SftpFileService.rename ok"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.rename ok"); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.rename failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.rename "+fullPathOld+" -> "+fullPathNew+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
fDirChannelMutex.release();
|
fDirChannelMutex.release();
|
||||||
|
@ -922,6 +923,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
Activator.trace("SftpFileService.runCommand ok, result: "+result); //$NON-NLS-1$
|
Activator.trace("SftpFileService.runCommand ok, result: "+result); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
Activator.trace(command);
|
||||||
Activator.trace("SftpFileService.runCommand failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.runCommand failed: "+e.toString()); //$NON-NLS-1$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -997,14 +999,14 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
long timestamp, IProgressMonitor monitor) throws SystemMessageException
|
long timestamp, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
boolean ok=false;
|
boolean ok=false;
|
||||||
|
String path = concat(parent, name);
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String path = concat(parent, name);
|
|
||||||
getChannel("SftpFileService.setLastModified").setMtime(recode(path), (int)(timestamp/1000)); //$NON-NLS-1$
|
getChannel("SftpFileService.setLastModified").setMtime(recode(path), (int)(timestamp/1000)); //$NON-NLS-1$
|
||||||
ok=true;
|
ok=true;
|
||||||
Activator.trace("SftpFileService.setLastModified ok"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.setLastModified ok"); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.setLastModified failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.setLastModified "+path+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
fDirChannelMutex.release();
|
fDirChannelMutex.release();
|
||||||
|
@ -1016,9 +1018,9 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
public boolean setReadOnly(String parent, String name,
|
public boolean setReadOnly(String parent, String name,
|
||||||
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
|
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
|
||||||
boolean ok=false;
|
boolean ok=false;
|
||||||
|
String path = concat(parent, name);
|
||||||
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
|
||||||
try {
|
try {
|
||||||
String path = concat(parent, name);
|
|
||||||
SftpATTRS attr = getChannel("SftpFileService.setReadOnly").stat(recode(path)); //$NON-NLS-1$
|
SftpATTRS attr = getChannel("SftpFileService.setReadOnly").stat(recode(path)); //$NON-NLS-1$
|
||||||
int permOld = attr.getPermissions();
|
int permOld = attr.getPermissions();
|
||||||
int permNew = permOld;
|
int permNew = permOld;
|
||||||
|
@ -1038,7 +1040,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
Activator.trace("SftpFileService.setReadOnly nothing-to-do"); //$NON-NLS-1$
|
Activator.trace("SftpFileService.setReadOnly nothing-to-do"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.setReadOnly failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SftpFileService.setReadOnly "+path+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
} finally {
|
} finally {
|
||||||
fDirChannelMutex.release();
|
fDirChannelMutex.release();
|
||||||
|
@ -1056,16 +1058,17 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
|
|
||||||
InputStream stream = null;
|
InputStream stream = null;
|
||||||
|
|
||||||
|
String remotePath = concat(remoteParent, remoteFile);
|
||||||
try {
|
try {
|
||||||
String remotePath = recode(concat(remoteParent, remoteFile));
|
String remotePathRecoded = recode(remotePath);
|
||||||
getChannel("SftpFileService.getInputStream " + remoteFile); //check the session is healthy //$NON-NLS-1$
|
getChannel("SftpFileService.getInputStream " + remoteFile); //check the session is healthy //$NON-NLS-1$
|
||||||
ChannelSftp channel = (ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
ChannelSftp channel = (ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
||||||
channel.connect();
|
channel.connect();
|
||||||
stream = new SftpBufferedInputStream(channel.get(remotePath), channel);
|
stream = new SftpBufferedInputStream(channel.get(remotePathRecoded), channel);
|
||||||
Activator.trace("SftpFileService.getInputStream " + remoteFile + " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.getInputStream " + remoteFile + " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.getInputStream " + remoteFile + " failed: " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.getInputStream " + remotePath + " failed: " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,21 +1087,14 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream stream = null;
|
OutputStream stream = null;
|
||||||
|
String dst = remoteParent;
|
||||||
|
if (remoteFile!=null) {
|
||||||
|
dst = concat(remoteParent, remoteFile);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
|
SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
|
||||||
int mode = ChannelSftp.OVERWRITE;
|
int mode = ChannelSftp.OVERWRITE;
|
||||||
String dst = remoteParent;
|
|
||||||
|
|
||||||
if (remoteFile != null) {
|
|
||||||
|
|
||||||
if (!dst.endsWith("/")) { //$NON-NLS-1$
|
|
||||||
dst += '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
dst += remoteFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
getChannel("SftpFileService.getOutputStream " + remoteFile); //check the session is healthy //$NON-NLS-1$
|
getChannel("SftpFileService.getOutputStream " + remoteFile); //check the session is healthy //$NON-NLS-1$
|
||||||
ChannelSftp channel = (ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
ChannelSftp channel = (ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
||||||
channel.connect();
|
channel.connect();
|
||||||
|
@ -1106,7 +1102,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
Activator.trace("SftpFileService.getOutputStream " + remoteFile + " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.getOutputStream " + remoteFile + " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Activator.trace("SftpFileService.getOutputStream " + remoteFile + " failed: " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.getOutputStream " + dst + " failed: " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw makeSystemMessageException(e);
|
throw makeSystemMessageException(e);
|
||||||
}
|
}
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue