Windream: Fix NewFolder

This commit is contained in:
Jonathan Jenne 2022-12-09 13:31:01 +01:00
parent 3883c0dad7
commit bd6d483867

View File

@ -638,6 +638,7 @@ Public Class Windream
Return False Return False
End Try End Try
End Function End Function
''' <summary> ''' <summary>
''' Archives windream object immediately ''' Archives windream object immediately
''' </summary> ''' </summary>
@ -654,7 +655,7 @@ Public Class Windream
End Try End Try
End Function End Function
Public Function NewFolder(Path As String, pExtension As String) As Boolean Public Function NewFolder(Path As String) As Boolean
If Not TestSessionLoggedIn() Then If Not TestSessionLoggedIn() Then
Return False Return False
End If End If
@ -665,13 +666,11 @@ Public Class Windream
Dim oFolderObject As WMObject Dim oFolderObject As WMObject
Dim oCurrentPath As String = String.Empty Dim oCurrentPath As String = String.Empty
For Each oFolder In oFolders For Each oFolder In oFolders
If oFolder.ToString.EndsWith(pExtension) Then If oFolder = String.Empty Then
Exit For
ElseIf oFolder = String.Empty Then
Continue For Continue For
End If End If
oCurrentPath = Combine(oCurrentPath, oFolder) oCurrentPath = Combine(oCurrentPath, oFolder)
If TestFolderExists(oCurrentPath) = False Then If TestFolderExists(oCurrentPath) = False Then
@ -706,13 +705,13 @@ Public Class Windream
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
NewDocumentID = 0 NewDocumentID = 0
Dim oExtension As String = Path.GetExtension(FilenameSource)
If Not TestSessionLoggedIn() Then If Not TestSessionLoggedIn() Then
Return False Return False
End If End If
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget) Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
FilenameTarget = GetNormalizedPath(FilenameTarget, True) FilenameTarget = GetNormalizedPath(FilenameTarget, True)
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}") _logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
@ -721,7 +720,7 @@ Public Class Windream
Dim oFileIO As WMFileIO Dim oFileIO As WMFileIO
Dim oWMStream As WMStream Dim oWMStream As WMStream
NewFolder(FilenameTarget, oExtension) NewFolder(oTargetDrive)
'Indexierungsdialog der Session unterdrücken 'Indexierungsdialog der Session unterdrücken
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False) Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
@ -816,10 +815,12 @@ Public Class Windream
Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String
_logger.Debug("Normalizing Path: [{0}]", Path) _logger.Debug("Normalizing Path: [{0}]", Path)
Dim oNormalizedPath As String = Path Dim oNormalizedPath As String = Path
If pCleanPath = True Then If pCleanPath = True Then
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path) oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
_logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath) _logger.Debug("Path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If End If
Try Try
' Convert any forward slashes / and double slashes \\ into backslashes \ ' Convert any forward slashes / and double slashes \\ into backslashes \
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes ' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
@ -830,7 +831,7 @@ Public Class Windream
' Remove Driveletter, eg. W:\ ' Remove Driveletter, eg. W:\
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2) oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]") _logger.Debug($"Path after replaced ClientDriveLetter: [{oNormalizedPath}]")
End If End If
' Remove Windream Base Path, eg. \\windream\objects\ ' Remove Windream Base Path, eg. \\windream\objects\
@ -845,14 +846,16 @@ Public Class Windream
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]") _logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
oNormalizedPath = oNormalizedPath.Substring(3) oNormalizedPath = oNormalizedPath.Substring(3)
End If End If
If oNormalizedPath.StartsWith("\") = False Then If oNormalizedPath.StartsWith("\") = False Then
oNormalizedPath = $"\{oNormalizedPath}" oNormalizedPath = $"\{oNormalizedPath}"
End If End If
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
_logger.Debug($"NormalizedPath: [{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 - NormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
Return "" Return ""
End Try End Try
End Function End Function