diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index d45b4b1..2ac1c7e 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -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 diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb index 8d3eb30..cdb129a 100644 --- a/GBM/Managers/mgrBackup.vb +++ b/GBM/Managers/mgrBackup.vb @@ -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 diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index b409610..9a80a86 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -1887,6 +1887,15 @@ Namespace My.Resources End Get End Property + ''' + ''' 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.. + ''' + Friend ReadOnly Property frmGameManager_ConfirmBackupImportOverwriteSingle() As String + Get + Return ResourceManager.GetString("frmGameManager_ConfirmBackupImportOverwriteSingle", resourceCulture) + End Get + End Property + ''' ''' 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.. ''' @@ -2473,7 +2482,7 @@ Namespace My.Resources End Property ''' - ''' 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.. ''' Friend ReadOnly Property frmGameManager_WarningImportBackupSaveMulti() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 7ab3bcf..2e3e6a6 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2255,7 +2255,7 @@ [PARAM] is a reserved variable, you must enter a different name. - The "Save multiple backups" option must be enabled on this configuration to import backup files. + The "Save multiple backups" option must be enabled on this configuration to import multiple backup files. &Linux... @@ -2266,4 +2266,7 @@ 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. + + Importing this backup file will overwrite the current backup file for [PARAM].[BR][BR]Do you want to continue? This will close the form. + \ No newline at end of file