Re-done duplicate detection fixes for issue #98
This commit is contained in:
@@ -1497,7 +1497,7 @@ Public Class frmMain
|
|||||||
|
|
||||||
Private Sub CheckForSavedDuplicate()
|
Private Sub CheckForSavedDuplicate()
|
||||||
For Each o As clsGame In oProcess.DuplicateList
|
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.GameInfo = o
|
||||||
oProcess.Duplicate = False
|
oProcess.Duplicate = False
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ Public Class mgrMonitorList
|
|||||||
Dim hshDupeList As New Hashtable
|
Dim hshDupeList As New Hashtable
|
||||||
Dim oGame As clsGame
|
Dim oGame As clsGame
|
||||||
Dim oCompareGame As clsGame
|
Dim oCompareGame As clsGame
|
||||||
|
Dim bIsDupe As Boolean
|
||||||
|
|
||||||
sSQL = "Select * from monitorlist ORDER BY Name Asc"
|
sSQL = "Select * from monitorlist ORDER BY Name Asc"
|
||||||
oData = oDatabase.ReadParamData(sSQL, New Hashtable)
|
oData = oDatabase.ReadParamData(sSQL, New Hashtable)
|
||||||
@@ -88,8 +89,32 @@ Public Class mgrMonitorList
|
|||||||
hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame)
|
hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame)
|
||||||
Case eListTypes.ScanList
|
Case eListTypes.ScanList
|
||||||
For Each de As DictionaryEntry In hshList
|
For Each de As DictionaryEntry In hshList
|
||||||
|
bIsDupe = False
|
||||||
oCompareGame = DirectCast(de.Value, clsGame)
|
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
|
DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True
|
||||||
oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName
|
oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName
|
||||||
oGame.Duplicate = True
|
oGame.Duplicate = True
|
||||||
|
|||||||
@@ -84,19 +84,43 @@ Public Class mgrProcesses
|
|||||||
|
|
||||||
Private Function HandleDuplicates(hshScanList As Hashtable) As Boolean
|
Private Function HandleDuplicates(hshScanList As Hashtable) As Boolean
|
||||||
Dim sProcess As String
|
Dim sProcess As String
|
||||||
|
Dim sParameter As String = String.Empty
|
||||||
|
Dim bParameter As Boolean = False
|
||||||
|
Dim oInitialDupes As New ArrayList
|
||||||
|
|
||||||
bDuplicates = True
|
bDuplicates = True
|
||||||
oDuplicateGames.Clear()
|
oDuplicateGames.Clear()
|
||||||
|
|
||||||
|
|
||||||
For Each o As clsGame In hshScanList.Values
|
For Each o As clsGame In hshScanList.Values
|
||||||
sProcess = o.ProcessName.Split(":")(0)
|
sProcess = o.ProcessName.Split(":")(0)
|
||||||
|
|
||||||
If o.Duplicate = True And (sProcess = oGame.TrueProcess Or Regex.IsMatch(sProcess, oGame.TrueProcess)) Then
|
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
|
oInitialDupes.Add(o.ShallowCopy)
|
||||||
oDuplicateGames.Add(o.ShallowCopy)
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
Next
|
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
|
If oDuplicateGames.Count = 1 Then
|
||||||
oGame = DirectCast(oDuplicateGames(0), clsGame).ShallowCopy
|
oGame = DirectCast(oDuplicateGames(0), clsGame).ShallowCopy
|
||||||
Return True
|
Return True
|
||||||
@@ -131,7 +155,7 @@ Public Class mgrProcesses
|
|||||||
|
|
||||||
'This function will only work correctly on Unix
|
'This function will only work correctly on Unix
|
||||||
Private Function GetUnixProcessArguments(ByVal prs As Process) As String()
|
Private Function GetUnixProcessArguments(ByVal prs As Process) As String()
|
||||||
Dim sArguments As String
|
Dim sArguments As String
|
||||||
Try
|
Try
|
||||||
sArguments = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline")
|
sArguments = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline")
|
||||||
Return sArguments.Split(vbNullChar)
|
Return sArguments.Split(vbNullChar)
|
||||||
@@ -226,8 +250,6 @@ Public Class mgrProcesses
|
|||||||
GetWindowsCommand(prsCurrent)
|
GetWindowsCommand(prsCurrent)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
FullCommand = FullCommand.Substring(prsCurrent.ProcessName.Length).Trim
|
|
||||||
|
|
||||||
If oGame.Duplicate = True Then
|
If oGame.Duplicate = True Then
|
||||||
If HandleDuplicates(hshScanList) Then
|
If HandleDuplicates(hshScanList) Then
|
||||||
bDuplicates = False
|
bDuplicates = False
|
||||||
|
|||||||
Reference in New Issue
Block a user