Changes for #151 - Pass 1: Functional, needs testing, code slimming and UI fixes
This commit is contained in:
@@ -112,7 +112,12 @@ Public Class clsGame
|
|||||||
bAbsolutePath = value
|
bAbsolutePath = value
|
||||||
End Set
|
End Set
|
||||||
Get
|
Get
|
||||||
|
'This makes sure a registry key path isn't seen as a relative path.
|
||||||
|
If mgrPath.IsSupportedRegistryPath(TruePath) Then
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
Return bAbsolutePath
|
Return bAbsolutePath
|
||||||
|
End If
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
|||||||
@@ -221,11 +221,15 @@ Public Class frmMain
|
|||||||
|
|
||||||
bOSVerified = VerifyBackupForOS(oGame, oRestoreInfo.RestorePath)
|
bOSVerified = VerifyBackupForOS(oGame, oRestoreInfo.RestorePath)
|
||||||
|
|
||||||
|
If mgrPath.IsSupportedRegistryPath(oRestoreInfo.TruePath) Then
|
||||||
|
bPathVerified = True
|
||||||
|
Else
|
||||||
If mgrRestore.CheckPath(oRestoreInfo, oGame, bTriggerReload) Then
|
If mgrRestore.CheckPath(oRestoreInfo, oGame, bTriggerReload) Then
|
||||||
bPathVerified = True
|
bPathVerified = True
|
||||||
Else
|
Else
|
||||||
UpdateLog(mgrCommon.FormatString(frmMain_ErrorRestorePath, oRestoreInfo.Name), False, ToolTipIcon.Error, True)
|
UpdateLog(mgrCommon.FormatString(frmMain_ErrorRestorePath, oRestoreInfo.Name), False, ToolTipIcon.Error, True)
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
If bOSVerified And bPathVerified Then
|
If bOSVerified And bPathVerified Then
|
||||||
If oRestore.CheckRestorePrereq(oRestoreInfo, oGame.CleanFolder) Then
|
If oRestore.CheckRestorePrereq(oRestoreInfo, oGame.CleanFolder) Then
|
||||||
@@ -2112,16 +2116,16 @@ Public Class frmMain
|
|||||||
If DoMultiGameCheck() Then
|
If DoMultiGameCheck() Then
|
||||||
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
|
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
|
||||||
If oProcess.WineProcess Then
|
If oProcess.WineProcess Then
|
||||||
|
oProcess.WineData.MonitorID = oProcess.GameInfo.ID
|
||||||
'Attempt a path conversion if the game configuration is using an absolute windows path that we can convert
|
'Attempt a path conversion if the game configuration is using an absolute windows path that we can convert
|
||||||
If mgrVariables.CheckForReservedVariables(oProcess.GameInfo.TruePath) Then
|
If mgrVariables.CheckForReservedVariables(oProcess.GameInfo.TruePath) Then
|
||||||
oProcess.WineData.MonitorID = oProcess.GameInfo.ID
|
|
||||||
oProcess.WineData.SavePath = mgrPath.GetWineSavePath(oProcess.WineData.Prefix, oProcess.GameInfo.TruePath)
|
oProcess.WineData.SavePath = mgrPath.GetWineSavePath(oProcess.WineData.Prefix, oProcess.GameInfo.TruePath)
|
||||||
If Not oProcess.WineData.SavePath = oProcess.GameInfo.TruePath Then
|
If Not oProcess.WineData.SavePath = oProcess.GameInfo.TruePath Then
|
||||||
oProcess.GameInfo.TruePath = oProcess.WineData.SavePath
|
oProcess.GameInfo.TruePath = oProcess.WineData.SavePath
|
||||||
mgrWineData.DoWineDataAddUpdate(oProcess.WineData)
|
|
||||||
UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, oProcess.WineData.SavePath), False)
|
UpdateLog(mgrCommon.FormatString(frmMain_WineSavePath, oProcess.WineData.SavePath), False)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
mgrWineData.DoWineDataAddUpdate(oProcess.WineData)
|
||||||
'This does required mods to include/exclude data and relative paths (if required)
|
'This does required mods to include/exclude data and relative paths (if required)
|
||||||
mgrPath.ModWinePathData(oProcess.GameInfo)
|
mgrPath.ModWinePathData(oProcess.GameInfo)
|
||||||
End If
|
End If
|
||||||
|
|||||||
+143
-41
@@ -120,10 +120,20 @@ Public Class mgrBackup
|
|||||||
Dim lAvailableSpace As Long
|
Dim lAvailableSpace As Long
|
||||||
Dim lFolderSize As Long = 0
|
Dim lFolderSize As Long = 0
|
||||||
Dim sDeepFolder As String
|
Dim sDeepFolder As String
|
||||||
|
Dim bRegistry As Boolean
|
||||||
|
Dim sExtension As String
|
||||||
|
|
||||||
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
|
'Check if this is a registry backup
|
||||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & ".7z"
|
bRegistry = mgrPath.IsSupportedRegistryPath(oGame.TruePath)
|
||||||
|
|
||||||
|
If bRegistry Then
|
||||||
|
'If this is a registry backup, we need to have elevated permissions in Windows to use regedit
|
||||||
|
If Not mgrCommon.IsUnix And Not mgrCommon.IsElevated Then
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorRegBackupElevation, oGame.Name), False, ToolTipIcon.Info, True)
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
sExtension = ".reg"
|
||||||
|
Else
|
||||||
'Verify saved game path
|
'Verify saved game path
|
||||||
sSavePath = VerifySavePath(oGame)
|
sSavePath = VerifySavePath(oGame)
|
||||||
|
|
||||||
@@ -162,6 +172,13 @@ Public Class mgrBackup
|
|||||||
If Not Settings.DisableDiskSpaceCheck Then RaiseEvent UpdateLog(mgrBackup_ErrorBackupPathIsUNC, False, ToolTipIcon.Info, True)
|
If Not Settings.DisableDiskSpaceCheck Then RaiseEvent UpdateLog(mgrBackup_ErrorBackupPathIsUNC, False, ToolTipIcon.Info, True)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
sExtension = ".7z"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
|
||||||
|
|
||||||
|
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & sExtension
|
||||||
|
|
||||||
'A manifest check is only required when "Save Multiple Backups" is disabled
|
'A manifest check is only required when "Save Multiple Backups" is disabled
|
||||||
If Not oGame.AppendTimeStamp Then
|
If Not oGame.AppendTimeStamp Then
|
||||||
If mgrRestore.CheckManifest(oGame.ID) Then
|
If mgrRestore.CheckManifest(oGame.ID) Then
|
||||||
@@ -292,44 +309,84 @@ Public Class mgrBackup
|
|||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub DoBackup(ByVal oBackupList As List(Of clsGame))
|
Private Function RunRegistryBackup(ByVal oGame As clsGame, ByVal sBackupFile As String) As Boolean
|
||||||
Dim oGame As clsGame
|
Dim prsReg As New Process
|
||||||
Dim bDoBackup As Boolean
|
Dim sBinaryPath As String
|
||||||
Dim bBackupCompleted As Boolean
|
|
||||||
Dim prs7z As Process
|
|
||||||
Dim sBackupFile As String
|
|
||||||
Dim sSavePath As String
|
|
||||||
Dim dTimeStamp As DateTime
|
|
||||||
Dim sTimeStamp As String
|
|
||||||
Dim sHash As String
|
|
||||||
Dim sArguments As String
|
Dim sArguments As String
|
||||||
|
Dim oWineData As clsWineData
|
||||||
|
Dim sWineRegEdit As String
|
||||||
|
Dim bPathVerified As Boolean = False
|
||||||
|
Dim bBackupCompleted As Boolean = False
|
||||||
|
|
||||||
For Each oGame In oBackupList
|
sArguments = "export """ & oGame.TruePath & """ """ & sBackupFile & """"
|
||||||
'Init
|
|
||||||
prs7z = New Process
|
|
||||||
sBackupFile = oSettings.BackupFolder
|
|
||||||
sSavePath = String.Empty
|
|
||||||
dTimeStamp = Date.Now
|
|
||||||
sTimeStamp = BuildFileTimeStamp(dTimeStamp)
|
|
||||||
sHash = String.Empty
|
|
||||||
bDoBackup = True
|
|
||||||
bBackupCompleted = False
|
|
||||||
CancelOperation = False
|
|
||||||
RaiseEvent UpdateBackupInfo(oGame)
|
|
||||||
|
|
||||||
If oSettings.CreateSubFolder Then
|
If mgrCommon.IsUnix Then
|
||||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
|
oWineData = mgrWineData.DoWineDataGetbyID(oGame.ID)
|
||||||
bDoBackup = HandleSubFolder(oGame, sBackupFile)
|
sBinaryPath = oWineData.BinaryPath & Path.DirectorySeparatorChar & "wine"
|
||||||
End If
|
sWineRegEdit = oWineData.Prefix & Path.DirectorySeparatorChar & "drive_c/windows/system32/reg.exe"
|
||||||
|
sArguments = """" & sWineRegEdit & """ " & sArguments
|
||||||
If oGame.AppendTimeStamp Then
|
If File.Exists(sBinaryPath) Then
|
||||||
If oGame.BackupLimit > 0 Then CheckOldBackups(oGame)
|
If File.Exists(sWineRegEdit) Then
|
||||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & sTimeStamp & ".7z"
|
bPathVerified = True
|
||||||
Else
|
Else
|
||||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & ".7z"
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorRegNotFound, sWineRegEdit), False, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorWineNotFound, sBinaryPath), False, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
sBinaryPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows) & Path.DirectorySeparatorChar & "system32\reg.exe"
|
||||||
|
If File.Exists(sBinaryPath) Then
|
||||||
|
bPathVerified = True
|
||||||
|
Else
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorRegNotFound, sBinaryPath), False, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If bDoBackup Then
|
If bPathVerified Then
|
||||||
|
Try
|
||||||
|
'Need to delete any prior file if it exists, otherwise reg.exe will get stuck waiting for input it'll never get.
|
||||||
|
If File.Exists(sBackupFile) Then
|
||||||
|
File.Delete(sBackupFile)
|
||||||
|
End If
|
||||||
|
|
||||||
|
prsReg.StartInfo.Arguments = sArguments
|
||||||
|
prsReg.StartInfo.FileName = sBinaryPath
|
||||||
|
prsReg.StartInfo.UseShellExecute = False
|
||||||
|
prsReg.StartInfo.RedirectStandardOutput = True
|
||||||
|
prsReg.StartInfo.CreateNoWindow = True
|
||||||
|
prsReg.Start()
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupInProgress, oGame.TruePath), False, ToolTipIcon.Info, True)
|
||||||
|
While Not prsReg.StandardOutput.EndOfStream
|
||||||
|
If CancelOperation Then
|
||||||
|
prsReg.Kill()
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorFullAbort, oGame.Name), True, ToolTipIcon.Error, True)
|
||||||
|
Exit While
|
||||||
|
End If
|
||||||
|
RaiseEvent UpdateLog(prsReg.StandardOutput.ReadLine, False, ToolTipIcon.Info, False)
|
||||||
|
End While
|
||||||
|
prsReg.WaitForExit()
|
||||||
|
Select Case prsReg.ExitCode
|
||||||
|
Case 0
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupComplete, New String() {oGame.Name, mgrCommon.FormatDiskSpace(mgrCommon.GetFileSize(sBackupFile))}), False, ToolTipIcon.Info, True)
|
||||||
|
bBackupCompleted = True
|
||||||
|
Case Else
|
||||||
|
RaiseEvent UpdateLog(mgrBackup_ErrorRegBackupFailed, False, ToolTipIcon.Info, True)
|
||||||
|
End Select
|
||||||
|
prsReg.Dispose()
|
||||||
|
Catch ex As Exception
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorOtherFailure, New String() {oGame.Name, ex.Message}), False, ToolTipIcon.Error, True)
|
||||||
|
End Try
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return bBackupCompleted
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function Run7zBackup(ByVal oGame As clsGame, ByVal sBackupFile As String) As Boolean
|
||||||
|
Dim prs7z As New Process
|
||||||
|
Dim sSavePath As String
|
||||||
|
Dim sArguments As String
|
||||||
|
Dim bBackupCompleted As Boolean = False
|
||||||
|
|
||||||
sSavePath = VerifySavePath(oGame)
|
sSavePath = VerifySavePath(oGame)
|
||||||
|
|
||||||
@@ -381,25 +438,73 @@ Public Class mgrBackup
|
|||||||
bBackupCompleted = True
|
bBackupCompleted = True
|
||||||
Case 2
|
Case 2
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_7zFatalError, oGame.Name), True, ToolTipIcon.Error, True)
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_7zFatalError, oGame.Name), True, ToolTipIcon.Error, True)
|
||||||
bBackupCompleted = False
|
|
||||||
Case 7
|
Case 7
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_7zCommandFailure, oGame.Name), True, ToolTipIcon.Error, True)
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_7zCommandFailure, oGame.Name), True, ToolTipIcon.Error, True)
|
||||||
bBackupCompleted = False
|
|
||||||
End Select
|
End Select
|
||||||
End If
|
End If
|
||||||
prs7z.Dispose()
|
prs7z.Dispose()
|
||||||
Else
|
Else
|
||||||
RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True)
|
RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True)
|
||||||
bBackupCompleted = False
|
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorNoSavePath, oGame.Name), True, ToolTipIcon.Error, True)
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorNoSavePath, oGame.Name), True, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorOtherFailure, New String() {oGame.Name, ex.Message}), False, ToolTipIcon.Error, True)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return bBackupCompleted
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Sub DoBackup(ByVal oBackupList As List(Of clsGame))
|
||||||
|
Dim oGame As clsGame
|
||||||
|
Dim bDoBackup As Boolean
|
||||||
|
Dim sBackupFile As String
|
||||||
|
Dim sBackupExt As String
|
||||||
|
Dim dTimeStamp As DateTime
|
||||||
|
Dim sTimeStamp As String
|
||||||
|
Dim sHash As String
|
||||||
|
Dim bBackupCompleted As Boolean
|
||||||
|
|
||||||
|
For Each oGame In oBackupList
|
||||||
|
'Init
|
||||||
|
sBackupFile = oSettings.BackupFolder
|
||||||
|
dTimeStamp = Date.Now
|
||||||
|
sTimeStamp = BuildFileTimeStamp(dTimeStamp)
|
||||||
|
sHash = String.Empty
|
||||||
|
bDoBackup = True
|
||||||
bBackupCompleted = False
|
bBackupCompleted = False
|
||||||
|
CancelOperation = False
|
||||||
|
RaiseEvent UpdateBackupInfo(oGame)
|
||||||
|
|
||||||
|
If oSettings.CreateSubFolder Then
|
||||||
|
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
|
||||||
|
bDoBackup = HandleSubFolder(oGame, sBackupFile)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If mgrPath.IsSupportedRegistryPath(oGame.TruePath) Then
|
||||||
|
sBackupExt = ".reg"
|
||||||
|
Else
|
||||||
|
sBackupExt = ".7z"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If oGame.AppendTimeStamp Then
|
||||||
|
If oGame.BackupLimit > 0 Then CheckOldBackups(oGame)
|
||||||
|
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & sTimeStamp & sBackupExt
|
||||||
|
Else
|
||||||
|
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & sBackupExt
|
||||||
|
End If
|
||||||
|
|
||||||
|
If bDoBackup Then
|
||||||
|
'Choose Backup Type
|
||||||
|
If mgrPath.IsSupportedRegistryPath(oGame.TruePath) Then
|
||||||
|
bBackupCompleted = RunRegistryBackup(oGame, sBackupFile)
|
||||||
|
Else
|
||||||
|
bBackupCompleted = Run7zBackup(oGame, sBackupFile)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'Write Main Manifest
|
'Write Main Manifest
|
||||||
If bBackupCompleted Then
|
If bBackupCompleted Then
|
||||||
|
|
||||||
'Generate checksum for new backup
|
'Generate checksum for new backup
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_GenerateHash, oGame.Name), False, ToolTipIcon.Info, True)
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_GenerateHash, oGame.Name), False, ToolTipIcon.Info, True)
|
||||||
sHash = mgrHash.Generate_SHA256_Hash(sBackupFile)
|
sHash = mgrHash.Generate_SHA256_Hash(sBackupFile)
|
||||||
@@ -413,9 +518,6 @@ Public Class mgrBackup
|
|||||||
mgrMonitorList.DoListFieldUpdate("ProcessPath", oGame.ProcessPath, oGame.ID)
|
mgrMonitorList.DoListFieldUpdate("ProcessPath", oGame.ProcessPath, oGame.ID)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorOtherFailure, New String() {oGame.Name, ex.Message}), False, ToolTipIcon.Error, True)
|
|
||||||
End Try
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If bBackupCompleted Then
|
If bBackupCompleted Then
|
||||||
|
|||||||
@@ -485,6 +485,16 @@ Public Class mgrPath
|
|||||||
Return sValue
|
Return sValue
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Shared Function IsSupportedRegistryPath(ByVal sPath As String)
|
||||||
|
If sPath.StartsWith("HKEY_CURRENT_USER") Then
|
||||||
|
Return True
|
||||||
|
ElseIf sPath.StartsWith("HKEY_LOCAL_MACHINE") Then
|
||||||
|
Return True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return False
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Shared Function IsPathUNC(sPath As String) As Boolean
|
Public Shared Function IsPathUNC(sPath As String) As Boolean
|
||||||
Dim sPrefix As String = Path.DirectorySeparatorChar & Path.DirectorySeparatorChar
|
Dim sPrefix As String = Path.DirectorySeparatorChar & Path.DirectorySeparatorChar
|
||||||
If sPath.StartsWith(sPrefix) Then Return True
|
If sPath.StartsWith(sPrefix) Then Return True
|
||||||
|
|||||||
+100
-21
@@ -122,8 +122,19 @@ Public Class mgrRestore
|
|||||||
Public Function CheckRestorePrereq(ByVal oBackupInfo As clsBackup, ByVal bCleanFolder As Boolean) As Boolean
|
Public Function CheckRestorePrereq(ByVal oBackupInfo As clsBackup, ByVal bCleanFolder As Boolean) As Boolean
|
||||||
Dim sHash As String
|
Dim sHash As String
|
||||||
Dim sExtractPath As String
|
Dim sExtractPath As String
|
||||||
|
Dim bRegistry As Boolean
|
||||||
Dim sBackupFile As String = oSettings.BackupFolder & Path.DirectorySeparatorChar & oBackupInfo.FileName
|
Dim sBackupFile As String = oSettings.BackupFolder & Path.DirectorySeparatorChar & oBackupInfo.FileName
|
||||||
|
|
||||||
|
'Check if this is a registry backup
|
||||||
|
bRegistry = mgrPath.IsSupportedRegistryPath(oBackupInfo.TruePath)
|
||||||
|
|
||||||
|
If bRegistry Then
|
||||||
|
'If this is a registry backup, we need to have elevated permissions in Windows to use regedit
|
||||||
|
If Not mgrCommon.IsUnix And Not mgrCommon.IsElevated Then
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorRegBackupElevation, oBackupInfo.Name), False, ToolTipIcon.Info, True)
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
Else
|
||||||
If oBackupInfo.AbsolutePath Then
|
If oBackupInfo.AbsolutePath Then
|
||||||
sExtractPath = oBackupInfo.RestorePath
|
sExtractPath = oBackupInfo.RestorePath
|
||||||
Else
|
Else
|
||||||
@@ -149,6 +160,7 @@ Public Class mgrRestore
|
|||||||
Directory.CreateDirectory(sExtractPath)
|
Directory.CreateDirectory(sExtractPath)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
'Check file integrity
|
'Check file integrity
|
||||||
If oBackupInfo.CheckSum <> String.Empty Then
|
If oBackupInfo.CheckSum <> String.Empty Then
|
||||||
@@ -170,20 +182,70 @@ Public Class mgrRestore
|
|||||||
Return True
|
Return True
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Sub DoRestore(ByVal oRestoreList As List(Of clsBackup))
|
Private Function RunRegistryRestore(ByVal oBackupInfo As clsBackup, ByVal sBackupFile As String) As Boolean
|
||||||
Dim prs7z As Process
|
Dim prsReg As New Process
|
||||||
Dim sBackupFile As String
|
Dim sBinaryPath As String
|
||||||
Dim sExtractPath As String
|
Dim sArguments As String
|
||||||
Dim bRestoreCompleted As Boolean
|
Dim oWineData As clsWineData
|
||||||
|
Dim sWineRegEdit As String
|
||||||
|
Dim bPathVerified As Boolean
|
||||||
|
Dim bRestoreCompleted As Boolean = False
|
||||||
|
|
||||||
For Each oBackupInfo In oRestoreList
|
sArguments = "import """ & sBackupFile & """"
|
||||||
'Init
|
|
||||||
prs7z = New Process
|
If mgrCommon.IsUnix Then
|
||||||
sBackupFile = oSettings.BackupFolder & Path.DirectorySeparatorChar & oBackupInfo.FileName
|
oWineData = mgrWineData.DoWineDataGetbyID(oBackupInfo.MonitorID)
|
||||||
sExtractPath = String.Empty
|
sBinaryPath = oWineData.BinaryPath & Path.DirectorySeparatorChar & "wine"
|
||||||
bRestoreCompleted = False
|
sWineRegEdit = oWineData.Prefix & Path.DirectorySeparatorChar & "drive_c/windows/system32/reg.exe"
|
||||||
CancelOperation = False
|
sArguments = """" & sWineRegEdit & """ " & sArguments
|
||||||
RaiseEvent UpdateRestoreInfo(oBackupInfo)
|
If File.Exists(sBinaryPath) Then
|
||||||
|
If File.Exists(sWineRegEdit) Then
|
||||||
|
bPathVerified = True
|
||||||
|
Else
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorRegNotFound, sWineRegEdit), False, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorWineNotFound, sBinaryPath), False, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
sBinaryPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows) & Path.DirectorySeparatorChar & "system32\reg.exe"
|
||||||
|
If File.Exists(sBinaryPath) Then
|
||||||
|
bPathVerified = True
|
||||||
|
Else
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorRegNotFound, sBinaryPath), False, ToolTipIcon.Error, True)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If bPathVerified Then
|
||||||
|
Try
|
||||||
|
prsReg.StartInfo.Arguments = sArguments
|
||||||
|
prsReg.StartInfo.FileName = sBinaryPath
|
||||||
|
prsReg.StartInfo.UseShellExecute = False
|
||||||
|
prsReg.StartInfo.RedirectStandardOutput = True
|
||||||
|
prsReg.StartInfo.CreateNoWindow = True
|
||||||
|
prsReg.Start()
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreInProgress, oBackupInfo.TruePath), False, ToolTipIcon.Info, True)
|
||||||
|
prsReg.WaitForExit()
|
||||||
|
Select Case prsReg.ExitCode
|
||||||
|
Case 0
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreComplete, oBackupInfo.Name), False, ToolTipIcon.Info, True)
|
||||||
|
bRestoreCompleted = True
|
||||||
|
Case Else
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreWarnings, oBackupInfo.Name), True, ToolTipIcon.Warning, True)
|
||||||
|
End Select
|
||||||
|
prsReg.Dispose()
|
||||||
|
Catch ex As Exception
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorOtherFailure, ex.Message), False, ToolTipIcon.Error, True)
|
||||||
|
End Try
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return bRestoreCompleted
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function Run7zRestore(ByVal oBackupInfo As clsBackup, ByVal sBackupFile As String) As Boolean
|
||||||
|
Dim prs7z As New Process
|
||||||
|
Dim sExtractPath As String
|
||||||
|
Dim bRestoreCompleted As Boolean = False
|
||||||
|
|
||||||
If oBackupInfo.AbsolutePath Then
|
If oBackupInfo.AbsolutePath Then
|
||||||
sExtractPath = oBackupInfo.RestorePath
|
sExtractPath = oBackupInfo.RestorePath
|
||||||
@@ -216,17 +278,40 @@ Public Class mgrRestore
|
|||||||
bRestoreCompleted = True
|
bRestoreCompleted = True
|
||||||
Else
|
Else
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreWarnings, oBackupInfo.Name), True, ToolTipIcon.Warning, True)
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreWarnings, oBackupInfo.Name), True, ToolTipIcon.Warning, True)
|
||||||
bRestoreCompleted = False
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
prs7z.Dispose()
|
prs7z.Dispose()
|
||||||
Else
|
Else
|
||||||
RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True)
|
RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True)
|
||||||
bRestoreCompleted = False
|
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
RaiseEvent UpdateLog(mgrRestore_ErrorNoBackup, True, ToolTipIcon.Error, True)
|
RaiseEvent UpdateLog(mgrRestore_ErrorNoBackup, True, ToolTipIcon.Error, True)
|
||||||
End If
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorOtherFailure, ex.Message), False, ToolTipIcon.Error, True)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return bRestoreCompleted
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Sub DoRestore(ByVal oRestoreList As List(Of clsBackup))
|
||||||
|
Dim sBackupFile As String
|
||||||
|
Dim sExtractPath As String
|
||||||
|
Dim bRestoreCompleted As Boolean
|
||||||
|
|
||||||
|
For Each oBackupInfo In oRestoreList
|
||||||
|
'Init
|
||||||
|
sBackupFile = oSettings.BackupFolder & Path.DirectorySeparatorChar & oBackupInfo.FileName
|
||||||
|
sExtractPath = String.Empty
|
||||||
|
bRestoreCompleted = False
|
||||||
|
CancelOperation = False
|
||||||
|
RaiseEvent UpdateRestoreInfo(oBackupInfo)
|
||||||
|
|
||||||
|
If mgrPath.IsSupportedRegistryPath(oBackupInfo.TruePath) Then
|
||||||
|
bRestoreCompleted = RunRegistryRestore(oBackupInfo, sBackupFile)
|
||||||
|
Else
|
||||||
|
bRestoreCompleted = Run7zRestore(oBackupInfo, sBackupFile)
|
||||||
|
End If
|
||||||
|
|
||||||
If bRestoreCompleted Then
|
If bRestoreCompleted Then
|
||||||
'Save Local Manifest
|
'Save Local Manifest
|
||||||
@@ -235,12 +320,6 @@ Public Class mgrRestore
|
|||||||
Else
|
Else
|
||||||
mgrManifest.DoManifestAdd(oBackupInfo, mgrSQLite.Database.Local)
|
mgrManifest.DoManifestAdd(oBackupInfo, mgrSQLite.Database.Local)
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorOtherFailure, ex.Message), False, ToolTipIcon.Error, True)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
If bRestoreCompleted Then
|
|
||||||
RaiseEvent SetLastAction(mgrCommon.FormatString(mgrRestore_ActionComplete, oBackupInfo.CroppedName))
|
RaiseEvent SetLastAction(mgrCommon.FormatString(mgrRestore_ActionComplete, oBackupInfo.CroppedName))
|
||||||
Else
|
Else
|
||||||
RaiseEvent SetLastAction(mgrCommon.FormatString(mgrRestore_ActionFailed, oBackupInfo.CroppedName))
|
RaiseEvent SetLastAction(mgrCommon.FormatString(mgrRestore_ActionFailed, oBackupInfo.CroppedName))
|
||||||
|
|||||||
Generated
+63
@@ -6123,6 +6123,33 @@ Namespace My.Resources
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to [PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to perform this backup..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrBackup_ErrorRegBackupElevation() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrBackup_ErrorRegBackupElevation", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to The backup has failed, please ensure the registry path is correct..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrBackup_ErrorRegBackupFailed() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrBackup_ErrorRegBackupFailed", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to The regedit utility could not be located at [PARAM]. The backup cannot continue..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrBackup_ErrorRegNotFound() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrBackup_ErrorRegNotFound", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
'''<summary>
|
'''<summary>
|
||||||
''' Looks up a localized string similar to A failure occured while creating a backup sub-folder for [PARAM].[BR][PARAM].
|
''' Looks up a localized string similar to A failure occured while creating a backup sub-folder for [PARAM].[BR][PARAM].
|
||||||
'''</summary>
|
'''</summary>
|
||||||
@@ -6132,6 +6159,15 @@ Namespace My.Resources
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to The wine binary could not be located at [PARAM]. The backup cannot continue..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrBackup_ErrorWineNotFound() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrBackup_ErrorWineNotFound", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
'''<summary>
|
'''<summary>
|
||||||
''' Looks up a localized string similar to Generating SHA-256 hash for [PARAM] backup file..
|
''' Looks up a localized string similar to Generating SHA-256 hash for [PARAM] backup file..
|
||||||
'''</summary>
|
'''</summary>
|
||||||
@@ -6636,6 +6672,33 @@ Namespace My.Resources
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to [PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to restore this backup..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrRestore_ErrorRegBackupElevation() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrRestore_ErrorRegBackupElevation", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to The regedit utility could not be located at [PARAM]. The restore cannot continue..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrRestore_ErrorRegNotFound() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrRestore_ErrorRegNotFound", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to The wine binary could not be located at [PARAM]. The restore cannot continue..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrRestore_ErrorWineNotFound() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrRestore_ErrorWineNotFound", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
'''<summary>
|
'''<summary>
|
||||||
''' Looks up a localized string similar to [PARAM] has no stored checksum, verification has been skipped..
|
''' Looks up a localized string similar to [PARAM] has no stored checksum, verification has been skipped..
|
||||||
'''</summary>
|
'''</summary>
|
||||||
|
|||||||
@@ -2347,4 +2347,25 @@
|
|||||||
<data name="frmSettings_ErrorLinuxAutoStart" xml:space="preserve">
|
<data name="frmSettings_ErrorLinuxAutoStart" xml:space="preserve">
|
||||||
<value>An error occured while creating the autostart link:[BR][BR][PARAM]</value>
|
<value>An error occured while creating the autostart link:[BR][BR][PARAM]</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="mgrBackup_ErrorRegBackupElevation" xml:space="preserve">
|
||||||
|
<value>[PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to perform this backup.</value>
|
||||||
|
</data>
|
||||||
|
<data name="mgrBackup_ErrorRegBackupFailed" xml:space="preserve">
|
||||||
|
<value>The backup has failed, please ensure the registry path is correct.</value>
|
||||||
|
</data>
|
||||||
|
<data name="mgrBackup_ErrorRegNotFound" xml:space="preserve">
|
||||||
|
<value>The regedit utility could not be located at [PARAM]. The backup cannot continue.</value>
|
||||||
|
</data>
|
||||||
|
<data name="mgrBackup_ErrorWineNotFound" xml:space="preserve">
|
||||||
|
<value>The wine binary could not be located at [PARAM]. The backup cannot continue.</value>
|
||||||
|
</data>
|
||||||
|
<data name="mgrRestore_ErrorRegNotFound" xml:space="preserve">
|
||||||
|
<value>The regedit utility could not be located at [PARAM]. The restore cannot continue.</value>
|
||||||
|
</data>
|
||||||
|
<data name="mgrRestore_ErrorWineNotFound" xml:space="preserve">
|
||||||
|
<value>The wine binary could not be located at [PARAM]. The restore cannot continue.</value>
|
||||||
|
</data>
|
||||||
|
<data name="mgrRestore_ErrorRegBackupElevation" xml:space="preserve">
|
||||||
|
<value>[PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to restore this backup.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user