This class serves two main purposes.
-
To provide a correct way of running sftp commands on Windows server.
Current implementation of commons-vfs calls
id -G
or id -u
,
which is incorrect for Windows.
-
To provide a way to release sftp connections, when we're done.
commons-vfs says we do not close fileSystemManager until application shutdown
(see VFS-454).
Thus, we need to close the connections.
There is AbstractFileProvider.freeUnusedResources()
,
which we can use to achieve this. But, unfortunately, original SftpFileSystem only releases them
when all file objects it's associated with are garbage collected. This is too restrictive and inconvenient.
Here we make the sftp file system object releasable when there are open file objects,
we only need i/o streams to be closed.
This is pretty safe to do. Even a file object would want to open a stream once again (currently wouldn't),
the file system object re-creates session and opens a new connection.
This provider replaces
SftpFileProvider
in FileSystemManager (see overridden providers.xml).
And then used to spawn SftpFileSystemWindows and SftpFileObjectWithWindowsSupport.