diff --git a/GBM/Classes/clsBackup.vb b/GBM/Classes/clsBackup.vb
index eef77cc..b42af69 100644
--- a/GBM/Classes/clsBackup.vb
+++ b/GBM/Classes/clsBackup.vb
@@ -7,8 +7,6 @@
Private sRelativeRestorePath As String = String.Empty
Private dDateUpdated As DateTime = Date.Now
Private sUpdatedBy As String = String.Empty
- Private dLastDateUpdated As DateTime = Date.Now
- Private sLastUpdatedBy As String = String.Empty
Private sCheckSum As String = String.Empty
Property ID As String
@@ -109,24 +107,6 @@
End Set
End Property
- Property LastDateUpdated As DateTime
- Get
- Return dLastDateUpdated
- End Get
- Set(value As DateTime)
- dLastDateUpdated = value
- End Set
- End Property
-
- Property LastUpdatedBy As String
- Get
- Return sLastUpdatedBy
- End Get
- Set(value As String)
- sLastUpdatedBy = value
- End Set
- End Property
-
Property CheckSum As String
Get
Return sCheckSum
diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb
index fccfc70..2834803 100644
--- a/GBM/Forms/frmMain.vb
+++ b/GBM/Forms/frmMain.vb
@@ -40,12 +40,14 @@ Public Class frmMain
Private sPriorVersion As String
Private iFormHeight As Integer
Private iLogSpacer As Integer
+ Private iRestoreTimeOut As Integer
'Developer Debug Flags
Private bProcessDebugMode As Boolean = False
WithEvents oFileWatcher As New System.IO.FileSystemWatcher
WithEvents tmScanTimer As New Timer
+ WithEvents tmRestoreCheck As New Timer
Public WithEvents oProcess As New mgrProcesses
Public WithEvents oBackup As New mgrBackup
@@ -53,6 +55,7 @@ Public Class frmMain
Public hshScanList As Hashtable
Public oSettings As New mgrSettings
+ Delegate Sub UpdateNotifierCallBack(ByVal iCount As Integer)
Delegate Sub UpdateLogCallBack(ByVal sLogUpdate As String, ByVal bTrayUpdate As Boolean, ByVal objIcon As System.Windows.Forms.ToolTipIcon, ByVal bTimeStamp As Boolean)
Delegate Sub WorkingGameInfoCallBack(ByVal sTitle As String, ByVal sStatus1 As String, ByVal sStatus2 As String, ByVal sStatus3 As String)
Delegate Sub UpdateStatusCallBack(ByVal sStatus As String)
@@ -328,15 +331,17 @@ Public Class frmMain
End If
End Sub
- Private Sub CheckRestore()
- Dim slRestoreData As SortedList = mgrRestore.CompareManifests()
- Dim sNotification As String
-
- If slRestoreData.Count > 0 Then
- If slRestoreData.Count > 1 Then
- sNotification = mgrCommon.FormatString(frmMain_NewSaveNotificationMulti, slRestoreData.Count)
+ Private Sub UpdateNotifier(ByVal iCount As Integer)
+ 'Thread Safe
+ If Me.InvokeRequired = True Then
+ Dim d As New UpdateNotifierCallBack(AddressOf UpdateNotifier)
+ Me.Invoke(d, New Object() {iCount})
+ Else
+ Dim sNotification As String
+ If iCount > 1 Then
+ sNotification = mgrCommon.FormatString(frmMain_NewSaveNotificationMulti, iCount)
Else
- sNotification = mgrCommon.FormatString(frmMain_NewSaveNotificationSingle, slRestoreData.Count)
+ sNotification = mgrCommon.FormatString(frmMain_NewSaveNotificationSingle, iCount)
End If
gMonNotification.Image = Icon_Inbox
gMonTrayNotification.Image = Icon_Inbox
@@ -347,6 +352,90 @@ Public Class frmMain
End If
End Sub
+ Private Sub StartRestoreCheck()
+ iRestoreTimeOut = -1
+ tmRestoreCheck.Interval = 60000
+ tmRestoreCheck.Enabled = True
+ tmRestoreCheck.Start()
+ AutoRestoreCheck()
+ End Sub
+
+ Private Sub AutoRestoreCheck()
+ Dim slRestoreData As SortedList = mgrRestore.CompareManifests()
+ Dim sNotReady As New List(Of String)
+ Dim sNotInstalled As New List(Of String)
+ Dim oBackup As clsBackup
+ Dim sFileName As String
+ Dim sExtractPath As String
+ Dim bFinished As Boolean = True
+
+ 'Bail out and shut down the timer if there's nothing to do
+ If slRestoreData.Count = 0 Then
+ tmRestoreCheck.Stop()
+ tmRestoreCheck.Enabled = False
+ Exit Sub
+ End If
+
+ 'Increment Timer
+ iRestoreTimeOut += 1
+
+ 'Check backup files
+ For Each de As DictionaryEntry In slRestoreData
+ oBackup = DirectCast(de.Value, clsBackup)
+
+ 'Check if backup file is ready to restore
+ sFileName = oSettings.BackupFolder & IO.Path.DirectorySeparatorChar & oBackup.FileName
+ If mgrHash.Generate_SHA256_Hash(sFileName) <> oBackup.CheckSum Then
+ sNotReady.Add(de.Key)
+ bFinished = False
+ End If
+
+ 'Check if the restore location exists, if not we assume the game is not installed and should be auto-marked.
+ If oBackup.AbsolutePath Then
+ sExtractPath = oBackup.RestorePath
+ Else
+ sExtractPath = oBackup.RelativeRestorePath
+ End If
+ If Not IO.Directory.Exists(sExtractPath) Then
+ If mgrManifest.DoGlobalManifestCheck(de.Key, mgrSQLite.Database.Local) Then
+ mgrManifest.DoManifestUpdateByName(de.Value, mgrSQLite.Database.Local)
+ Else
+ mgrManifest.DoManifestAdd(de.Value, mgrSQLite.Database.Local)
+ End If
+ sNotInstalled.Add(de.Key)
+ End If
+ Next
+
+ 'Remove any backup files that are not ready
+ For Each s As String In sNotReady
+ slRestoreData.Remove(s)
+ UpdateLog(mgrCommon.FormatString(frmMain_RestoreNotReady, s), False, ToolTipIcon.Info, True)
+ Next
+
+ 'Remove any backup files that should not be automatically restored
+ For Each s As String In sNotInstalled
+ slRestoreData.Remove(s)
+ UpdateLog(mgrCommon.FormatString(frmMain_AutoMarked, s), False, ToolTipIcon.Info, True)
+ Next
+
+ 'When backup files are ready update the notifier
+ If slRestoreData.Count > 0 Then
+ UpdateNotifier(slRestoreData.Count)
+ End If
+
+ 'Shutdown if we are finished
+ If bFinished Then
+ tmRestoreCheck.Stop()
+ tmRestoreCheck.Enabled = False
+ End If
+
+ 'Time out after 15 minutes
+ If iRestoreTimeOut = 15 Then
+ tmRestoreCheck.Stop()
+ tmRestoreCheck.Enabled = False
+ End If
+ End Sub
+
'Functions handling the display of game information
Private Sub SetIcon()
Dim sIcon As String
@@ -758,7 +847,7 @@ Public Class frmMain
Private Sub CheckForNewBackups()
If oSettings.RestoreOnLaunch Then
- CheckRestore()
+ StartRestoreCheck()
End If
End Sub
@@ -1100,6 +1189,9 @@ Public Class frmMain
End Sub
Private Sub SetForm()
+ 'Disable Autosize in Linux (Mono prevents manual resizing when this is enabled)
+ If mgrCommon.IsUnix Then Me.AutoSize = False
+
'Set Form Name
Me.Name = App_NameLong
@@ -1522,6 +1614,10 @@ Public Class frmMain
End If
End Sub
+ Private Sub AutoRestoreEventProcessor(myObject As Object, ByVal myEventArgs As EventArgs) Handles tmRestoreCheck.Tick
+ AutoRestoreCheck()
+ End Sub
+
Private Sub ScanTimerEventProcessor(myObject As Object, ByVal myEventArgs As EventArgs) Handles tmScanTimer.Tick
Dim bNeedsPath As Boolean = False
Dim bContinue As Boolean = True
diff --git a/GBM/Managers/mgrRestore.vb b/GBM/Managers/mgrRestore.vb
index 9039f74..30aca39 100644
--- a/GBM/Managers/mgrRestore.vb
+++ b/GBM/Managers/mgrRestore.vb
@@ -96,8 +96,6 @@ Public Class mgrRestore
If bLocal And bRemote Then
'Compare
If oRemoteItem.DateUpdated > oLocalItem.DateUpdated Then
- oRemoteItem.LastDateUpdated = oLocalItem.DateUpdated
- oRemoteItem.LastUpdatedBy = oLocalItem.UpdatedBy
Return True
End If
End If
@@ -126,16 +124,14 @@ Public Class mgrRestore
If oItem.DateUpdated > oLocalItem.DateUpdated Then
oLocalItem.FileName = oItem.FileName
- oLocalItem.LastDateUpdated = oItem.DateUpdated
- oLocalItem.LastUpdatedBy = oItem.UpdatedBy
+ oLocalItem.DateUpdated = oItem.DateUpdated
+ oLocalItem.UpdatedBy = oItem.UpdatedBy
slRestoreItems.Add(oLocalItem.Name, oLocalItem)
End If
Else
oLocalItem = oItem
- oLocalItem.LastDateUpdated = oItem.DateUpdated
- oLocalItem.LastUpdatedBy = oItem.UpdatedBy
- oLocalItem.DateUpdated = Nothing
- oLocalItem.UpdatedBy = Nothing
+ oLocalItem.DateUpdated = oItem.DateUpdated
+ oLocalItem.UpdatedBy = oItem.UpdatedBy
slRestoreItems.Add(oLocalItem.Name, oLocalItem)
End If
Next
diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb
index 27759c1..ccc409c 100644
--- a/GBM/My Project/Resources.Designer.vb
+++ b/GBM/My Project/Resources.Designer.vb
@@ -2301,6 +2301,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to The saved game folder for [PARAM] does not exist, the backup has been automatically marked as restored..
+ '''
+ Friend ReadOnly Property frmMain_AutoMarked() As String
+ Get
+ Return ResourceManager.GetString("frmMain_AutoMarked", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to Backup in Progress....
'''
@@ -3156,6 +3165,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to The backup file for [PARAM] is not ready to restore..
+ '''
+ Friend ReadOnly Property frmMain_RestoreNotReady() As String
+ Get
+ Return ResourceManager.GetString("frmMain_RestoreNotReady", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to GBM is running with Administrator privileges..
'''
diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx
index 5ee2c95..c9ac133 100644
--- a/GBM/My Project/Resources.resx
+++ b/GBM/My Project/Resources.resx
@@ -1735,4 +1735,10 @@
Clean folder on restore
+
+ The saved game folder for [PARAM] does not exist, the backup has been automatically marked as restored.
+
+
+ The backup file for [PARAM] is not ready to restore.
+
\ No newline at end of file