Improved import backup file functionality for #150
This commit is contained in:
@@ -1555,6 +1555,7 @@ Public Class frmGameManager
|
||||
Private Sub TriggerSelectedImportBackup()
|
||||
Dim sDefaultFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
|
||||
Dim oBackup As New mgrBackup
|
||||
Dim sConfirm As String = frmGameManager_ConfirmBackupImport
|
||||
Dim sFile As String
|
||||
Dim sFiles As String()
|
||||
|
||||
@@ -1577,7 +1578,16 @@ Public Class frmGameManager
|
||||
End If
|
||||
Next
|
||||
|
||||
If mgrCommon.ShowMessage(frmGameManager_ConfirmBackupImport, oCurrentGame.CroppedName, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
|
||||
If sFiles.Length > 1 And Not CurrentGame.AppendTimeStamp Then
|
||||
mgrCommon.ShowMessage(frmGameManager_WarningImportBackupSaveMulti, MsgBoxStyle.Exclamation)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If sFiles.Length = 1 And Not CurrentGame.AppendTimeStamp And mgrManifest.DoManifestCheck(CurrentGame.ID, mgrSQLite.Database.Remote) Then
|
||||
sConfirm = frmGameManager_ConfirmBackupImportOverwriteSingle
|
||||
End If
|
||||
|
||||
If mgrCommon.ShowMessage(sConfirm, oCurrentGame.CroppedName, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
|
||||
Me.TriggerImportBackup = True
|
||||
Me.Close()
|
||||
End If
|
||||
@@ -1941,11 +1951,7 @@ Public Class frmGameManager
|
||||
End Sub
|
||||
|
||||
Private Sub btnImportBackup_Click(sender As Object, e As EventArgs) Handles btnImportBackup.Click
|
||||
If CurrentGame.AppendTimeStamp Then
|
||||
TriggerSelectedImportBackup()
|
||||
Else
|
||||
mgrCommon.ShowMessage(frmGameManager_WarningImportBackupSaveMulti, MsgBoxStyle.Information)
|
||||
End If
|
||||
TriggerSelectedImportBackup()
|
||||
End Sub
|
||||
|
||||
Private Sub chkFolderSave_CheckedChanged(sender As Object, e As EventArgs) Handles chkFolderSave.CheckedChanged
|
||||
|
||||
@@ -215,6 +215,7 @@ Public Class mgrBackup
|
||||
|
||||
Public Sub ImportBackupFiles(ByVal hshImportList As Hashtable)
|
||||
Dim oGame As clsGame
|
||||
Dim bOverwriteCurrent As Boolean = False
|
||||
Dim bContinue As Boolean = True
|
||||
Dim sFileToImport As String
|
||||
Dim sBackupFile As String
|
||||
@@ -223,9 +224,13 @@ Public Class mgrBackup
|
||||
For Each de As DictionaryEntry In hshImportList
|
||||
sFileToImport = CStr(de.Key)
|
||||
oGame = DirectCast(de.Value, clsGame)
|
||||
If File.Exists(sFileToImport) Then
|
||||
|
||||
'Enter overwite mode if we are importing a single backup and "Save Multiple Backups" is not enabled.
|
||||
If hshImportList.Count = 1 And Not oGame.AppendTimeStamp Then bOverwriteCurrent = True
|
||||
|
||||
If File.Exists(sFileToImport) Then
|
||||
sBackupFile = oSettings.BackupFolder
|
||||
|
||||
If oSettings.CreateSubFolder Then
|
||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
|
||||
bContinue = HandleSubFolder(oGame, sBackupFile)
|
||||
@@ -236,14 +241,32 @@ Public Class mgrBackup
|
||||
oBackup.MonitorID = oGame.ID
|
||||
oBackup.DateUpdated = File.GetLastWriteTime(sFileToImport)
|
||||
oBackup.UpdatedBy = mgrBackup_ImportedFile
|
||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & BuildFileTimeStamp(oBackup.DateUpdated) & ".7z"
|
||||
oBackup.FileName = sBackupFile.Replace(Settings.BackupFolder & Path.DirectorySeparatorChar, String.Empty)
|
||||
If mgrCommon.CopyFile(sFileToImport, sBackupFile, False) Then
|
||||
oBackup.CheckSum = mgrHash.Generate_SHA256_Hash(sBackupFile)
|
||||
mgrManifest.DoManifestAdd(oBackup, mgrSQLite.Database.Remote)
|
||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ImportSuccess, New String() {sFileToImport, oGame.Name}), False, ToolTipIcon.Error, True)
|
||||
If bOverwriteCurrent Then
|
||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & ".7z"
|
||||
Else
|
||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorImportBackupCopy, sFileToImport), False, ToolTipIcon.Error, True)
|
||||
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & BuildFileTimeStamp(oBackup.DateUpdated) & ".7z"
|
||||
End If
|
||||
|
||||
oBackup.FileName = sBackupFile.Replace(Settings.BackupFolder & Path.DirectorySeparatorChar, String.Empty)
|
||||
|
||||
If bOverwriteCurrent Then
|
||||
If mgrCommon.CopyFile(sFileToImport, sBackupFile, True) Then
|
||||
oBackup.CheckSum = mgrHash.Generate_SHA256_Hash(sBackupFile)
|
||||
If Not mgrManifest.DoUpdateLatestManifest(oBackup, mgrSQLite.Database.Remote) Then
|
||||
mgrManifest.DoManifestAdd(oBackup, mgrSQLite.Database.Remote)
|
||||
End If
|
||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ImportSuccess, New String() {sFileToImport, oGame.Name}), False, ToolTipIcon.Info, True)
|
||||
Else
|
||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorImportBackupCopy, sFileToImport), False, ToolTipIcon.Error, True)
|
||||
End If
|
||||
Else
|
||||
If mgrCommon.CopyFile(sFileToImport, sBackupFile, False) Then
|
||||
oBackup.CheckSum = mgrHash.Generate_SHA256_Hash(sBackupFile)
|
||||
mgrManifest.DoManifestAdd(oBackup, mgrSQLite.Database.Remote)
|
||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ImportSuccess, New String() {sFileToImport, oGame.Name}), False, ToolTipIcon.Info, True)
|
||||
Else
|
||||
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorImportBackupCopy, sFileToImport), False, ToolTipIcon.Error, True)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Generated
+10
-1
@@ -1887,6 +1887,15 @@ Namespace My.Resources
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to Importing this backup file will overwrite the current backup file for [PARAM].[BR][BR]Do you want to continue? This will close the form..
|
||||
'''</summary>
|
||||
Friend ReadOnly Property frmGameManager_ConfirmBackupImportOverwriteSingle() As String
|
||||
Get
|
||||
Return ResourceManager.GetString("frmGameManager_ConfirmBackupImportOverwriteSingle", resourceCulture)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to Are you sure you want to delete [PARAM]? This cannot be undone.[BR][BR]This will not delete any backup files that already exist for this game..
|
||||
'''</summary>
|
||||
@@ -2473,7 +2482,7 @@ Namespace My.Resources
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to The "Save multiple backups" option must be enabled on this configuration to import backup files..
|
||||
''' Looks up a localized string similar to The "Save multiple backups" option must be enabled on this configuration to import multiple backup files..
|
||||
'''</summary>
|
||||
Friend ReadOnly Property frmGameManager_WarningImportBackupSaveMulti() As String
|
||||
Get
|
||||
|
||||
@@ -2255,7 +2255,7 @@
|
||||
<value>[PARAM] is a reserved variable, you must enter a different name.</value>
|
||||
</data>
|
||||
<data name="frmGameManager_WarningImportBackupSaveMulti" xml:space="preserve">
|
||||
<value>The "Save multiple backups" option must be enabled on this configuration to import backup files.</value>
|
||||
<value>The "Save multiple backups" option must be enabled on this configuration to import multiple backup files.</value>
|
||||
</data>
|
||||
<data name="frmGameManager_cmsOfficialLinux" xml:space="preserve">
|
||||
<value>&Linux...</value>
|
||||
@@ -2266,4 +2266,7 @@
|
||||
<data name="frmGameManager_WarningWinConfigsInLinux" xml:space="preserve">
|
||||
<value>Official Windows configurations can be used in Linux for games running in Wine or Proton.[BR][BR]You do not need to modify these configurations, GBM will automatically do any required path conversions the first time the game is detected.[BR][BR]This message will only be shown once.</value>
|
||||
</data>
|
||||
<data name="frmGameManager_ConfirmBackupImportOverwriteSingle" xml:space="preserve">
|
||||
<value>Importing this backup file will overwrite the current backup file for [PARAM].[BR][BR]Do you want to continue? This will close the form.</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user