Noticing 5.1.2 has come out, I updated WinSCP files and am testing my script again.
I still have the same issue and I notice one minor bug.
The bug is that if you set the
SessionOptions
SshHostKey
property, you can't 'unset' it. Setting
SshHostKey
, after it has a value, to
""
or
null
results in this error:
Exception setting "SshHostKey": "SSH host key fingerprint" does not match pattern /(ssh-rsa |ssh-dss )?\d+ ([0-9a-f]{2}:){15}[0-9a-f]{2}(;(ssh-rsa |ssh-dss )?\d+ ([0-9a-f]{2}:){15}[0-9a-f]{2})*/
The situation is that you might first set
Protocol
to
SFTP
and set
SshHostKey
but later you may need to change the protocol to FTP. If you leave
SshHostKey
set then you cannot make the connection due to another exception that
SshHostKey
is set but
Protocol
is
FTP
.
The work around is to re-create the
SessionOption
s variable if you want to switch from
SFTP
to
FTP
.
It's clearly not a serious problem but you might consider to modify the regex for
SshHostKey
to allow empty string or ignore
SshHostKey
if
Protocol
is
FTP
instead of throwing an exception.
The second issue is the same as I earlier posted. In a batch-transfer situation, if any error is encountered the WinSCP process terminates and subsequent matching files are not transferred.
A potential situation is that occasionally the process that creates the target files to transfer could hang and a file become perpetually locked. In that case future files are not transferred because WinSCP keeps processing the locked file first and terminating on failure.
The third issue is that the order of file selection does not appear to be modifiable and this prevents a simple workaround for the previous issue.
PutFiles("c:\temp\*.txt", "./", $TRUE, $FTPTransferOptions)
This appears to operate on an alphabetical list of files that match the source filespec. The problem is that let's say that file
targetfile_5.txt
is locked or has some other issue,
targetfile_6.txt
is never touched by WinSCP. Some time later target files
7
,
8
,
9
are created, the
PutFiles
method is invoked again, but first up is
targetfile_5.txt
which is still locked. So any subsequent file, ordered alphabetically, will never be processed by WinSCP.
If the file list could be sorted by date from newest to oldest, naturally any problem file will be the oldest file so newer files would be processed first on subsequent passes.
I could find no simple way to re-order the files. I assume that WinSCP uses a .NET method to access the file list and the default .NET sort order is alphabetical.
Otherwise workarounds could include sending urgent email on error and understanding that transfers may fail until the issue is resolved, renaming any accessible source file so that 'good' files are alphabetically before 'bad' files or just recoding to send files individually instead of batching them.
Any chance of having WinSCP .NET assembly modified to continue on errors?