Closed Jo0 closed 4 years ago
Windows Test
var clientFactory = new SMB2ClientFactory();
var credentialProvider = new SMBCredentialProvider();
var fs = new SMBFileSystem(clientFactory, credentialProvider);
using var credential = new SMBCredential("<domain>", "<user>, "<password>", @"smb://<domain>/TestUncShare", credentialProvider);
var shareDriveInfo = fs.DriveInfo.FromDriveName("TestUncShare");
var sharePathDriveInfo = fs.DriveInfo.FromDriveName(@"smb://<domain>/TestUncShare");
var cDriveInfo = fs.DriveInfo.FromDriveName("C");
var cQualDriveInfo = fs.DriveInfo.FromDriveName("C:/");
var sharePathWithDir = @"smb://<domain>/TestUncShare/Test";
var localPath = @"C://temp/dir";
var pathshareDriveInfo = fs.DriveInfo.FromDriveName(sharePathWithDir.ShareName());
var pathsharePathDriveInfo = fs.DriveInfo.FromDriveName(fs.Path.GetPathRoot(sharePathWithDir));
var pathcDriveInfo = fs.DriveInfo.FromDriveName(fs.Path.GetPathRoot(localPath));
var shareDirInfo = fs.DirectoryInfo.FromDirectoryName(@"smb://<domain>/TestUncShare");
var localDirInfo = fs.DirectoryInfo.FromDirectoryName(@"C://temp");
var sharedirInfoDriveInfo = fs.DriveInfo.FromDriveName(shareDirInfo.Root.FullName);
var localDirInfoDriveInfo = fs.DriveInfo.FromDriveName(localDirInfo.Root.FullName);
Linux test
var clientFactory = new SMB2ClientFactory();
var credentialProvider = new SMBCredentialProvider();
var fs = new SMBFileSystem(clientFactory, credentialProvider);
using var credential = new SMBCredential("<domain>", "<user>", "<password>", @"smb://<domain>/TestUncShare", credentialProvider);
var shareDriveInfo = fs.DriveInfo.FromDriveName("TestUncShare");
var sharePathDriveInfo = fs.DriveInfo.FromDriveName(@"smb://<domain>/TestUncShare");
var rootDriveInfo = fs.DriveInfo.FromDriveName("/");
var localDriveInfo = fs.DriveInfo.FromDriveName("/home/<host user>");
var sharePathWithDir = @"smb://<domain>/TestUncShare/Test";
var rootPath = @"/";
var localPath = @"/home/<host user>";
var pathshareDriveInfo = fs.DriveInfo.FromDriveName(sharePathWithDir.ShareName());
var pathsharePathDriveInfo = fs.DriveInfo.FromDriveName(fs.Path.GetPathRoot(sharePathWithDir));
var pathrootDriveInfo = fs.DriveInfo.FromDriveName(fs.Path.GetRootPath(rootPath));
var pathrootLocalDriveInfo = fs.DriveInfo.FromDriveName(fs.Path.GetPathRoot(localPath));
var shareDirInfo = fs.DirectoryInfo.FromDirectoryName(@"smb://<domain>/TestUncShare");
var rootDirInfo = fs.DirectoryInfo.FromDirectoryName(@"/");
var localDirInfo = fs.DirectoryInfo.FromDirectoryName(@"/home/<host user>");
var sharedirInfoDriveInfo = fs.DriveInfo.FromDriveName(shareDirInfo.Root.FullName);
var rootDirInfoDriveInfo = fs.DriveInfo.FromDriveName(rootDirInfo.Root.FullName);
var localDirInfoDriveInfo = fs.DriveInfo.FromDriveName(localDirInfo.Root.FullName);
In
SMBDriveInfoFactory
we were failing to getDriveInfo
for Linux paths and potentially not flowing intoSystem.IO.DriveInfo
for Windows drive names.This PR flips the logic in
SMBDriveInfoFactory.FromDriveName
to flow into SMB logic if the input string is a share path or a input string[1] that does not exist inGetDrives()
of the host file system or does not match the acceptedDriveName
input.With the addition of logging, the
--logger:"console;verbosity=detailed"
flags were added to thedockerfile
to help trace issues with Linux testing from a Windows host.[1]
SMBPath.GetPathRoot()
returns the entire SharePath. If a consumer were to useSMBPath.GetPathRoot()
orSMBDirectoryInfo.Root.FullName
as input forSMBDriveInfoFactory.FromDriveName
, that is supported rather than just the explicit ShareName.