Relative path fix for issue #67

This commit is contained in:
Michael J. Seiferling
2017-02-22 12:49:19 -06:00
parent 974aaa3638
commit a5dd1d547b
3 changed files with 28 additions and 17 deletions
+24 -13
View File
@@ -1,4 +1,5 @@
Imports GBM.My.Resources Imports GBM.My.Resources
Imports System.IO
'Name: frmMain 'Name: frmMain
'Description: Game Backup Monitor Main Screen 'Description: Game Backup Monitor Main Screen
@@ -45,7 +46,7 @@ Public Class frmMain
'Developer Debug Flags 'Developer Debug Flags
Private bProcessDebugMode As Boolean = False Private bProcessDebugMode As Boolean = False
WithEvents oFileWatcher As New System.IO.FileSystemWatcher WithEvents oFileWatcher As New FileSystemWatcher
WithEvents tmScanTimer As New Timer WithEvents tmScanTimer As New Timer
WithEvents tmRestoreCheck As New Timer WithEvents tmRestoreCheck As New Timer
@@ -82,7 +83,7 @@ Public Class frmMain
Dim sStatus3 As String Dim sStatus3 As String
'Build Info 'Build Info
sStatus1 = IO.Path.GetFileName(oRestoreInfo.FileName) sStatus1 = Path.GetFileName(oRestoreInfo.FileName)
sStatus2 = mgrCommon.FormatString(frmMain_UpdatedBy, New String() {oRestoreInfo.UpdatedBy, oRestoreInfo.DateUpdated}) sStatus2 = mgrCommon.FormatString(frmMain_UpdatedBy, New String() {oRestoreInfo.UpdatedBy, oRestoreInfo.DateUpdated})
If oRestoreInfo.AbsolutePath Then If oRestoreInfo.AbsolutePath Then
sStatus3 = oRestoreInfo.RestorePath sStatus3 = oRestoreInfo.RestorePath
@@ -104,7 +105,7 @@ Public Class frmMain
If oGame.AbsolutePath Then If oGame.AbsolutePath Then
sStatus2 = oGame.Path sStatus2 = oGame.Path
Else Else
sStatus2 = oGame.ProcessPath & System.IO.Path.DirectorySeparatorChar & oGame.Path sStatus2 = oGame.ProcessPath & Path.DirectorySeparatorChar & oGame.Path
End If End If
sStatus3 = String.Empty sStatus3 = String.Empty
@@ -383,6 +384,7 @@ Public Class frmMain
Dim bFinished As Boolean = True Dim bFinished As Boolean = True
Dim hshRestore As Hashtable Dim hshRestore As Hashtable
Dim hshGames As Hashtable Dim hshGames As Hashtable
Dim oGame As clsGame
'Shut down the timer and bail out if there's nothing to do 'Shut down the timer and bail out if there's nothing to do
If slRestoreData.Count = 0 Then If slRestoreData.Count = 0 Then
@@ -400,7 +402,7 @@ Public Class frmMain
'Check if backup file is ready to restore 'Check if backup file is ready to restore
If oBackup.CheckSum <> String.Empty Then If oBackup.CheckSum <> String.Empty Then
sFileName = oSettings.BackupFolder & IO.Path.DirectorySeparatorChar & oBackup.FileName sFileName = oSettings.BackupFolder & Path.DirectorySeparatorChar & oBackup.FileName
If mgrHash.Generate_SHA256_Hash(sFileName) <> oBackup.CheckSum Then If mgrHash.Generate_SHA256_Hash(sFileName) <> oBackup.CheckSum Then
sNotReady.Add(de.Key) sNotReady.Add(de.Key)
bFinished = False bFinished = False
@@ -413,9 +415,17 @@ Public Class frmMain
If oBackup.AbsolutePath Then If oBackup.AbsolutePath Then
sExtractPath = oBackup.RestorePath sExtractPath = oBackup.RestorePath
Else Else
hshGames = mgrMonitorList.DoListGetbyName(de.Key)
If hshGames.Count = 1 Then
oGame = DirectCast(hshGames(0), clsGame)
If oGame.ProcessPath <> String.Empty Then
oBackup.RelativeRestorePath = oGame.ProcessPath & Path.DirectorySeparatorChar & oBackup.RestorePath
End If
End If
sExtractPath = oBackup.RelativeRestorePath sExtractPath = oBackup.RelativeRestorePath
End If End If
If Not IO.Directory.Exists(sExtractPath) Then
If Not Directory.Exists(sExtractPath) Then
If oSettings.AutoMark Then If oSettings.AutoMark Then
If mgrManifest.DoGlobalManifestCheck(de.Key, mgrSQLite.Database.Local) Then If mgrManifest.DoGlobalManifestCheck(de.Key, mgrSQLite.Database.Local) Then
mgrManifest.DoManifestUpdateByName(de.Value, mgrSQLite.Database.Local) mgrManifest.DoManifestUpdateByName(de.Value, mgrSQLite.Database.Local)
@@ -454,7 +464,8 @@ Public Class frmMain
For Each de As DictionaryEntry In slRestoreData For Each de As DictionaryEntry In slRestoreData
hshGames = mgrMonitorList.DoListGetbyName(de.Key) hshGames = mgrMonitorList.DoListGetbyName(de.Key)
If hshGames.Count = 1 Then If hshGames.Count = 1 Then
hshRestore.Add(hshGames(0), de.Value) oGame = DirectCast(hshGames(0), clsGame)
hshRestore.Add(oGame, de.Value)
Else Else
UpdateLog(mgrCommon.FormatString(frmMain_AutoRestoreFailure, de.Key), False, ToolTipIcon.Info, True) UpdateLog(mgrCommon.FormatString(frmMain_AutoRestoreFailure, de.Key), False, ToolTipIcon.Info, True)
End If End If
@@ -500,7 +511,7 @@ Public Class frmMain
End If End If
Try Try
fbBrowser.InitialDirectory = IO.Path.GetDirectoryName(oProcess.FoundProcess.MainModule.FileName) fbBrowser.InitialDirectory = Path.GetDirectoryName(oProcess.FoundProcess.MainModule.FileName)
Catch ex As Exception Catch ex As Exception
fbBrowser.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) fbBrowser.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
End Try End Try
@@ -508,7 +519,7 @@ Public Class frmMain
If fbBrowser.ShowDialog() = Windows.Forms.DialogResult.OK Then If fbBrowser.ShowDialog() = Windows.Forms.DialogResult.OK Then
sIcon = fbBrowser.FileName sIcon = fbBrowser.FileName
If IO.File.Exists(sIcon) Then If File.Exists(sIcon) Then
oProcess.GameInfo.Icon = sIcon oProcess.GameInfo.Icon = sIcon
pbIcon.Image = Image.FromFile(sIcon) pbIcon.Image = Image.FromFile(sIcon)
mgrMonitorList.DoListUpdate(oProcess.GameInfo) mgrMonitorList.DoListUpdate(oProcess.GameInfo)
@@ -599,7 +610,7 @@ Public Class frmMain
End Try End Try
'Check for a custom icon & details 'Check for a custom icon & details
If IO.File.Exists(oProcess.GameInfo.Icon) Then If File.Exists(oProcess.GameInfo.Icon) Then
pbIcon.Image = Image.FromFile(oProcess.GameInfo.Icon) pbIcon.Image = Image.FromFile(oProcess.GameInfo.Icon)
End If End If
If sFileName = String.Empty Then If sFileName = String.Empty Then
@@ -922,7 +933,7 @@ Public Class frmMain
If oSettings.Sync Then If oSettings.Sync Then
oFileWatcher.Path = oSettings.BackupFolder oFileWatcher.Path = oSettings.BackupFolder
oFileWatcher.Filter = "gbm.s3db" oFileWatcher.Filter = "gbm.s3db"
oFileWatcher.NotifyFilter = IO.NotifyFilters.LastWrite oFileWatcher.NotifyFilter = NotifyFilters.LastWrite
End If End If
End Sub End Sub
@@ -1400,9 +1411,9 @@ Public Class frmMain
Dim sSettingsRoot As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "/gbm" Dim sSettingsRoot As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "/gbm"
Dim sDBLocation As String = sSettingsRoot & "/gbm.s3db" Dim sDBLocation As String = sSettingsRoot & "/gbm.s3db"
If Not IO.Directory.Exists(sSettingsRoot) Then If Not Directory.Exists(sSettingsRoot) Then
Try Try
IO.Directory.CreateDirectory(sSettingsRoot) Directory.CreateDirectory(sSettingsRoot)
Catch ex As Exception Catch ex As Exception
mgrCommon.ShowMessage(frmMain_ErrorSettingsFolder, ex.Message, MsgBoxStyle.Critical) mgrCommon.ShowMessage(frmMain_ErrorSettingsFolder, ex.Message, MsgBoxStyle.Critical)
bShutdown = True bShutdown = True
@@ -1410,7 +1421,7 @@ Public Class frmMain
End Try End Try
End If End If
If Not IO.File.Exists(sDBLocation) Then bFirstRun = True If Not File.Exists(sDBLocation) Then bFirstRun = True
End Sub End Sub
Private Sub VerifyDBVersion(ByVal iDB As mgrSQLite.Database) Private Sub VerifyDBVersion(ByVal iDB As mgrSQLite.Database)
+2 -2
View File
@@ -2302,7 +2302,7 @@ Namespace My.Resources
End Property End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to The saved game folder for [PARAM] does not exist, the backup has been automatically marked as restored.. ''' Looks up a localized string similar to The saved game folder for [PARAM] does not exist or could not be determined, the backup has been automatically marked as restored..
'''</summary> '''</summary>
Friend ReadOnly Property frmMain_AutoMark() As String Friend ReadOnly Property frmMain_AutoMark() As String
Get Get
@@ -3103,7 +3103,7 @@ Namespace My.Resources
End Property End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to The saved game folder for [PARAM] does not exist, this backup has been skipped.. ''' Looks up a localized string similar to The saved game folder for [PARAM] does not exist or could not be determined, this backup has been skipped..
'''</summary> '''</summary>
Friend ReadOnly Property frmMain_NoAutoMark() As String Friend ReadOnly Property frmMain_NoAutoMark() As String
Get Get
+2 -2
View File
@@ -1736,7 +1736,7 @@
<value>Clean folder on restore</value> <value>Clean folder on restore</value>
</data> </data>
<data name="frmMain_AutoMark" xml:space="preserve"> <data name="frmMain_AutoMark" xml:space="preserve">
<value>The saved game folder for [PARAM] does not exist, the backup has been automatically marked as restored.</value> <value>The saved game folder for [PARAM] does not exist or could not be determined, the backup has been automatically marked as restored.</value>
</data> </data>
<data name="frmMain_RestoreNotReady" xml:space="preserve"> <data name="frmMain_RestoreNotReady" xml:space="preserve">
<value>The backup file for [PARAM] is not ready to restore.</value> <value>The backup file for [PARAM] is not ready to restore.</value>
@@ -1760,7 +1760,7 @@
<value>[PARAM] New Backup Restored</value> <value>[PARAM] New Backup Restored</value>
</data> </data>
<data name="frmMain_NoAutoMark" xml:space="preserve"> <data name="frmMain_NoAutoMark" xml:space="preserve">
<value>The saved game folder for [PARAM] does not exist, this backup has been skipped.</value> <value>The saved game folder for [PARAM] does not exist or could not be determined, this backup has been skipped.</value>
</data> </data>
<data name="frmMain_NoCheckSum" xml:space="preserve"> <data name="frmMain_NoCheckSum" xml:space="preserve">
<value>The backup file for [PARAM] has no checksum, it cannot be automatically restored.</value> <value>The backup file for [PARAM] has no checksum, it cannot be automatically restored.</value>