FileExists in DropTable: generate hash from filename for msg files

This commit is contained in:
Jonathan Jenne 2021-07-06 16:45:32 +02:00
parent a0c725163a
commit 5c44668002

View File

@ -1,21 +1,26 @@
Imports System.IO
Public Class ClassIndexFunctions
Public Shared Function FileExistsinDropTable(Filename As String) As Date
Public Shared Function FileExistsinDropTable(pFilename As String) As Date
Dim oSQL As String
Dim oHash As String
Try
If Filename.Contains("'") Then
Filename = Filename.Replace("'", "''")
If pFilename.Contains("'") Then
pFilename = pFilename.Replace("'", "''")
End If
' If file cannot be accessed, checksum cannot be generated
' In this case, the file should be treated as not yet existing
oHash = FILESYSTEM.GetChecksum(Filename)
If pFilename.ToUpper.EndsWith(".MSG") Then
' MSG Files cannot be hashed based on filecontents, so we use the filename instead
oHash = FILESYSTEM.GetChecksumFromString(pFilename)
Else
' If file cannot be accessed, checksum cannot be generated
' In this case, the file should be treated as not yet existing
oHash = FILESYSTEM.GetChecksum(pFilename)
End If
If oHash Is Nothing Then
LOGGER.Warn("Checksum for file {0} could not be generated. Treating as new file.", Filename)
LOGGER.Warn("Checksum for file {0} could not be generated. Treating as new file.", pFilename)
Return Nothing
End If