Re-done duplicate detection fixes for issue #98

This commit is contained in:
MikeMaximus
2018-02-23 13:32:58 -06:00
parent 0dbda50291
commit bb6e292c6f
3 changed files with 56 additions and 9 deletions
+1 -1
View File
@@ -1497,7 +1497,7 @@ Public Class frmMain
Private Sub CheckForSavedDuplicate()
For Each o As clsGame In oProcess.DuplicateList
If o.ProcessPath.ToLower = oProcess.GameInfo.ProcessPath.ToLower And o.Parameter = String.Empty Then
If o.ProcessPath.ToLower = oProcess.GameInfo.ProcessPath.ToLower Then
oProcess.GameInfo = o
oProcess.Duplicate = False
End If
+26 -1
View File
@@ -76,6 +76,7 @@ Public Class mgrMonitorList
Dim hshDupeList As New Hashtable
Dim oGame As clsGame
Dim oCompareGame As clsGame
Dim bIsDupe As Boolean
sSQL = "Select * from monitorlist ORDER BY Name Asc"
oData = oDatabase.ReadParamData(sSQL, New Hashtable)
@@ -88,8 +89,32 @@ Public Class mgrMonitorList
hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame)
Case eListTypes.ScanList
For Each de As DictionaryEntry In hshList
bIsDupe = False
oCompareGame = DirectCast(de.Value, clsGame)
If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then
If oCompareGame.IsRegEx Then
If oGame.IsRegEx Then
If oCompareGame.ProcessName = oGame.ProcessName Then
bIsDupe = True
End If
Else
If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Then
bIsDupe = True
End If
End If
Else
If oGame.IsRegEx Then
If Regex.IsMatch(oCompareGame.ProcessName, oGame.ProcessName) Then
bIsDupe = True
End If
Else
If oGame.ProcessName = oCompareGame.ProcessName Then
bIsDupe = True
End If
End If
End If
If bIsDupe Then
DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True
oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName
oGame.Duplicate = True
+29 -7
View File
@@ -84,19 +84,43 @@ Public Class mgrProcesses
Private Function HandleDuplicates(hshScanList As Hashtable) As Boolean
Dim sProcess As String
Dim sParameter As String = String.Empty
Dim bParameter As Boolean = False
Dim oInitialDupes As New ArrayList
bDuplicates = True
oDuplicateGames.Clear()
For Each o As clsGame In hshScanList.Values
sProcess = o.ProcessName.Split(":")(0)
If o.Duplicate = True And (sProcess = oGame.TrueProcess Or Regex.IsMatch(sProcess, oGame.TrueProcess)) Then
If (o.Parameter <> String.Empty And FullCommand.Contains(o.Parameter)) Or (o.Parameter = String.Empty And FullCommand = String.Empty) Then
oDuplicateGames.Add(o.ShallowCopy)
End If
oInitialDupes.Add(o.ShallowCopy)
End If
Next
For Each o As clsGame In oInitialDupes
If (o.Parameter <> String.Empty And FullCommand.Contains(o.Parameter)) Then
sParameter = o.Parameter
bParameter = True
Exit For
End If
Next
If bParameter Then
For Each o As clsGame In oInitialDupes
If (o.Parameter = sParameter) Then
oDuplicateGames.Add(o.ShallowCopy)
End If
Next
Else
For Each o As clsGame In oInitialDupes
If (o.Parameter = String.Empty) Then
oDuplicateGames.Add(o.ShallowCopy)
End If
Next
End If
If oDuplicateGames.Count = 1 Then
oGame = DirectCast(oDuplicateGames(0), clsGame).ShallowCopy
Return True
@@ -131,7 +155,7 @@ Public Class mgrProcesses
'This function will only work correctly on Unix
Private Function GetUnixProcessArguments(ByVal prs As Process) As String()
Dim sArguments As String
Dim sArguments As String
Try
sArguments = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline")
Return sArguments.Split(vbNullChar)
@@ -226,8 +250,6 @@ Public Class mgrProcesses
GetWindowsCommand(prsCurrent)
End If
FullCommand = FullCommand.Substring(prsCurrent.ProcessName.Length).Trim
If oGame.Duplicate = True Then
If HandleDuplicates(hshScanList) Then
bDuplicates = False