Clean filename for temp files, centralize windream basepath

This commit is contained in:
Jonathan Jenne
2021-09-21 16:36:34 +02:00
parent ab2a0134f7
commit 9c0c31e141
11 changed files with 211 additions and 218 deletions

View File

@@ -6,11 +6,25 @@ Imports DigitalData.Modules.Language
Imports Limilabs.Mail
Public Class ClassFilehandle
Public Shared Function Decide_FileHandle(pFilename As String, pHandletype As String)
Public Shared Function Decide_FileHandle(pFilepath As String, pHandletype As String)
Try
If pFilename.ToUpper.EndsWith(".MSG") Or pFilename.ToUpper.EndsWith(".EML") Then
'TODO: Before doing anything, clean the filename
Dim oFilename = IO.Path.GetFileName(pFilepath)
Dim oCleanFileName = Utils.RemoveInvalidCharacters(oFilename)
Dim oTempDirectory = IO.Path.GetTempPath()
Dim oTempFilePath = IO.Path.Combine(oTempDirectory, oCleanFileName)
Try
TEMP_FILES.Add(oTempFilePath)
IO.File.Copy(pFilepath, oTempFilePath, True)
Catch ex As Exception
LOGGER.Error(ex)
Throw ex
End Try
If oTempFilePath.ToUpper.EndsWith(".MSG") Or oTempFilePath.ToUpper.EndsWith(".EML") Then
CURRENT_MESSAGEID = ""
Dim oMail As IMail = EMAIL.Load_Email(pFilename)
Dim oMail As IMail = EMAIL.Load_Email(oTempFilePath)
If oMail.Attachments.Count > 0 Then
Dim oTitle As String
Dim oMessage As String
@@ -28,14 +42,15 @@ Public Class ClassFilehandle
' https://stackoverflow.com/questions/1220882/keep-messagebox-show-on-top-of-other-application-using-c-sharp
oResult = MessageBox.Show(oMessage, oTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
If oResult = MsgBoxResult.Yes Then
Dim oIsFolderWatch = pHandletype.StartsWith("|FW")
Return Save_EmailAndAttachmentsToDisk(pFilename, oIsFolderWatch)
Return Save_EmailAndAttachmentsToDisk(oTempFilePath, oIsFolderWatch)
End If
End If
End If
If pFilename.ToUpper.EndsWith(".LNK") Then
If oTempFilePath.ToUpper.EndsWith(".LNK") Then
If USER_LANGUAGE = "de-DE" Then
MsgBox("Verknüpfungen können nicht abgelegt werden!", MsgBoxStyle.Critical, "Global Indexer")
Else
@@ -44,7 +59,7 @@ Public Class ClassFilehandle
Return False
End If
Return Insert_GI_File(pFilename, pHandletype)
Return Insert_GI_File(oTempFilePath, pHandletype)
Catch ex As Exception
MsgBox("Unexpected Error in Decide_FileHandle: " & ex.Message, MsgBoxStyle.Critical)
Return False