mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
Bug 149150 - fix timestamps for ssh, other file services to be done
This commit is contained in:
parent
0df0fff7a6
commit
1ed80584e7
1 changed files with 31 additions and 1 deletions
|
@ -252,6 +252,19 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
channel=(ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
channel=(ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
|
||||||
channel.connect();
|
channel.connect();
|
||||||
channel.put(localFile.getAbsolutePath(), dst, sftpMonitor, mode); //$NON-NLS-1$
|
channel.put(localFile.getAbsolutePath(), dst, sftpMonitor, mode); //$NON-NLS-1$
|
||||||
|
SftpATTRS attr = channel.stat(dst);
|
||||||
|
attr.setACMODTIME(attr.getATime(), (int)(localFile.lastModified()/1000));
|
||||||
|
////TODO check if we want to maintain permissions
|
||||||
|
//if (!localFile.canWrite()) {
|
||||||
|
// attr.setPERMISSIONS( attr.getPermissions() & (~00400));
|
||||||
|
//}
|
||||||
|
channel.setStat(dst, attr);
|
||||||
|
if (attr.getSize() != localFile.length()) {
|
||||||
|
//Error: file truncated? - Inform the user!!
|
||||||
|
//TODO throw exception to show an error dialog!
|
||||||
|
System.err.println("ssh.upload: file size mismatch for "+dst);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Activator.trace("SftpFileService.upload "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-1$
|
Activator.trace("SftpFileService.upload "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -337,6 +350,17 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
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); //$NON-NLS-1$
|
channel.get(remotePath, localFile.getAbsolutePath(), sftpMonitor, mode); //$NON-NLS-1$
|
||||||
|
SftpATTRS attr = channel.stat(remotePath);
|
||||||
|
localFile.setLastModified(1000L * attr.getMTime());
|
||||||
|
//TODO should we set the read-only status?
|
||||||
|
//if (0==(attrs.getPermissions() & 00400)) localFile.setReadOnly();
|
||||||
|
if (attr.getSize() != localFile.length()) {
|
||||||
|
//Error: file truncated? - Inform the user!!
|
||||||
|
//TODO throw exception to show an error dialog!
|
||||||
|
System.err.println("ssh.download: file size mismatch for "+remotePath);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Activator.trace("SftpFileService.download "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.download "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -346,10 +370,16 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
//throw new RemoteFileIOException(e);
|
//throw new RemoteFileIOException(e);
|
||||||
Activator.trace("SftpFileService.download "+remoteFile+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
Activator.trace("SftpFileService.download "+remoteFile+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
//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
|
||||||
|
//broken incorrect file might be synchronized back to the source, thus
|
||||||
|
//destroying the original file!!
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (channel!=null) channel.disconnect();
|
if (channel!=null) {
|
||||||
|
channel.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue