Check dropped files by hash instead of filename #GI-12
This commit is contained in:
@@ -1,19 +1,38 @@
|
||||
|
||||
|
||||
Public Class ClassIndexFunctions
|
||||
Public Class ClassIndexFunctions
|
||||
Public Shared Function FileExistsinDropTable(Filename As String)
|
||||
Dim check As String
|
||||
Dim oSQL As String
|
||||
Dim oHash As String
|
||||
|
||||
Try
|
||||
If Filename.Contains("'") Then
|
||||
Filename = Filename.Replace("'", "''")
|
||||
End If
|
||||
check = "SELECT COUNT(*) FROM TBGI_FILES_USER WHERE UPPER(FILENAME2WORK) = UPPER('" & Filename & "') AND WORKED = 0"
|
||||
Dim result = ClassDatabase.Execute_Scalar(check, MyConnectionString, True)
|
||||
Return result
|
||||
|
||||
Try
|
||||
oHash = FILESYSTEM.GetChecksum(Filename)
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
oHash = ""
|
||||
End Try
|
||||
|
||||
oSQL = "SELECT COUNT(*) FROM TBGI_FILES_USER WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') AND WORKED = 0"
|
||||
Dim oResult = ClassDatabase.Execute_Scalar(oSQL, MyConnectionString, True)
|
||||
|
||||
If oResult = 0 Then
|
||||
oSQL = "SELECT COUNT(*) FROM TBGI_HISTORY WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "')"
|
||||
oResult = ClassDatabase.Execute_Scalar(oSQL, MyConnectionString, True)
|
||||
|
||||
If oResult = 0 Then
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in FileExistsinDropTable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & check, MsgBoxStyle.Critical)
|
||||
MsgBox("Error in FileExistsinDropTable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & oSQL, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user