From 64a01c97c534d3835a4549d0cadd0dd1b3c5df30 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Thu, 28 Feb 2019 08:22:27 -0600 Subject: [PATCH] Added a timed check to verify backup path for #180 --- GBM/Managers/mgrPath.vb | 33 ++++++++++++++++++---------- GBM/My Project/Resources.Designer.vb | 2 +- GBM/My Project/Resources.resx | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index b70556f..1542b70 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -2,6 +2,7 @@ Imports System.IO Imports System.Text.RegularExpressions Imports System.Reflection +Imports System.Threading.Thread Public Class mgrPath 'Important Note: Any changes to sSettingsRoot & sDBLocation need to be mirrored in frmMain.vb -> VerifyGameDataPath @@ -612,21 +613,31 @@ Public Class mgrPath Public Shared Function VerifyBackupPath(ByRef sBackupPath As String) As Boolean Dim dBrowser As FolderBrowserDialog + Dim oDialogResult As DialogResult + Dim iTotalWait As Integer + Dim iTimeOut As Integer = 60000 - If Not Directory.Exists(sBackupPath) Then - If mgrCommon.ShowMessage(mgrPath_ConfirmBackupLocation, sBackupPath, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - dBrowser = New FolderBrowserDialog - dBrowser.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) - If dBrowser.ShowDialog = DialogResult.OK Then - sBackupPath = dBrowser.SelectedPath - Return True - Else + Do While Not (Directory.Exists(sBackupPath)) + Sleep(5000) + iTotalWait += 5000 + If iTotalWait >= iTimeOut Then + oDialogResult = mgrCommon.ShowMessage(mgrPath_ConfirmBackupLocation, sBackupPath, MsgBoxStyle.YesNoCancel) + If oDialogResult = MsgBoxResult.Yes Then + dBrowser = New FolderBrowserDialog + dBrowser.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + If dBrowser.ShowDialog = DialogResult.OK Then + sBackupPath = dBrowser.SelectedPath + Return True + Else + Return False + End If + ElseIf oDialogResult = DialogResult.No Then Return False + Else + iTotalWait = 0 End If - Else - Return False End If - End If + Loop Return True End Function diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index d2684a1..23073a1 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -6439,7 +6439,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to The backup location [PARAM] is not available.[BR]It may be on an external or network drive that isn't connected.[BR][BR]Do you want to select another backup location and continue?. + ''' Looks up a localized string similar to The backup location [PARAM] is not available.[BR]It may be on an external or network drive that isn't connected.[BR][BR]Do you want to select another backup location?[BR][BR]Select "No" to quit or "Cancel" to continue waiting for the location to become available.. ''' Friend ReadOnly Property mgrPath_ConfirmBackupLocation() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index a1873cb..5681985 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1361,7 +1361,7 @@ [PARAM][BR][BR]Do you wish to automatically search for the game path? (Path will be saved) - The backup location [PARAM] is not available.[BR]It may be on an external or network drive that isn't connected.[BR][BR]Do you want to select another backup location and continue? + The backup location [PARAM] is not available.[BR]It may be on an external or network drive that isn't connected.[BR][BR]Do you want to select another backup location?[BR][BR]Select "No" to quit or "Cancel" to continue waiting for the location to become available. [PARAM][BR][BR]Do you wish to manually set the game path? (Path will be saved)