fix breaking unc path

This commit is contained in:
Jonathan Jenne 2020-05-29 10:53:38 +02:00
parent 8bd6cd63d4
commit 30827fb841

View File

@ -766,36 +766,36 @@ Public Class Windream
Public Function GetNormalizedPath(Path As String) As String Public Function GetNormalizedPath(Path As String) As String
Dim oNormalizedPath = GetCleanedPath(Path) Dim oNormalizedPath = GetCleanedPath(Path)
Try Try
' Remove Driveletter, eg. W:\
'If UsesDriveLetter Then
' Remove Driveletter eg. W:\
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
_logger.Debug($"Replacing ClientDriveLetter: [{ClientDriveLetter}]") _logger.Debug($"Replacing ClientDriveLetter: [{ClientDriveLetter}]")
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2) oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
End If End If
'Else
' Remove Windream Base Path, eg. \\windream\objects\
If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then
_logger.Debug($"Replacing ClientBasePath: [{ClientBasePath}]") _logger.Debug($"Replacing ClientBasePath: [{ClientBasePath}]")
' Remove Windream Base Path eg. \\windream\objects\
oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length - 1) oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length - 1)
End If End If
'End If
oNormalizedPath = oNormalizedPath.Replace("\\", "\") ' Convert any forward slashes / and double slashes \\ into backslashes \
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]") ' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
oNormalizedPath = GetFullPath(oNormalizedPath)
' Handle misconfigured drive-letter
If oNormalizedPath.Contains(":") Then If oNormalizedPath.Contains(":") Then
_logger.Info($"oNormalizedPath still contains a drive name!!") _logger.Warn($"oNormalizedPath still contains a drive name!!")
_logger.Info($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]") _logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
oNormalizedPath = oNormalizedPath.Substring(3) oNormalizedPath = oNormalizedPath.Substring(3)
_logger.Debug($"oNormalizedPath after Substring: [{oNormalizedPath}]")
End If End If
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
Return oNormalizedPath Return oNormalizedPath
Catch ex As Exception Catch ex As Exception
_logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]") _logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
Return "" Return ""
End Try End Try
End Function End Function
''' <summary> ''' <summary>