diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 169a7ff..2162e5f 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -175,7 +175,7 @@ Public Class frmGameManager Return sPath End Function - Private Sub CheckManifestandUpdate(ByVal oOriginalApp As clsGame, ByVal oNewApp As clsGame, ByVal bUseGameID As Boolean) + Private Function CheckManifestandUpdate(ByVal oOriginalApp As clsGame, ByVal oNewApp As clsGame, ByVal bUseGameID As Boolean) As Boolean Dim oBackupItems As List(Of clsBackup) Dim sDirectory As String Dim sNewDirectory As String @@ -195,6 +195,55 @@ Public Class frmGameManager sOriginalAppItem = oOriginalApp.FileSafeName End If + 'Remote + If mgrManifest.DoManifestCheck(oOriginalApp.ID, mgrSQLite.Database.Remote) Then + + 'Check for existing folder + sDirectory = BackupFolder & sOriginalAppItem + sNewDirectory = sDirectory.Replace(sOriginalAppItem, sNewAppItem) + If Directory.Exists(sNewDirectory) Then + If mgrCommon.ShowMessage(frmGameManager_ErrorRenameFolderExists, New String() {sDirectory, sNewDirectory}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + mgrCommon.DeleteDirectory(sNewDirectory, True) + Else + Return False + End If + End If + + oBackupItems = mgrManifest.DoManifestGetByMonitorID(oOriginalApp.ID, mgrSQLite.Database.Remote) + + 'Check for existing files + For Each oBackupItem As clsBackup In oBackupItems + 'Rename Current Backup File + sFileName = BackupFolder & oBackupItem.FileName + sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(sOriginalAppItem, sNewAppItem) + If File.Exists(sNewFileName) Then + If mgrCommon.ShowMessage(frmGameManager_ErrorRenameFilesExist, New String() {sOriginalAppItem, sNewAppItem}, MsgBoxStyle.YesNo) = MsgBoxResult.No Then + Return False + End If + Exit For + End If + Next + + 'Rename files + For Each oBackupItem As clsBackup In oBackupItems + 'Rename Current Backup File + sFileName = BackupFolder & oBackupItem.FileName + sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(sOriginalAppItem, sNewAppItem) + If File.Exists(sFileName) And Not sFileName = sNewFileName Then + If File.Exists(sNewFileName) Then mgrCommon.DeleteFile(sNewFileName) + FileSystem.Rename(sFileName, sNewFileName) + End If + oBackupItem.MonitorID = oNewApp.ID + oBackupItem.FileName = oBackupItem.FileName.Replace(sOriginalAppItem, sNewAppItem) + mgrManifest.DoManifestUpdateByManifestID(oBackupItem, mgrSQLite.Database.Remote) + Next + + 'Rename folder + If Directory.Exists(sDirectory) And Not sDirectory = sNewDirectory Then + FileSystem.Rename(sDirectory, sNewDirectory) + End If + End If + 'Local If mgrManifest.DoManifestCheck(oOriginalApp.ID, mgrSQLite.Database.Local) Then oBackupItems = mgrManifest.DoManifestGetByMonitorID(oOriginalApp.ID, mgrSQLite.Database.Local) @@ -205,33 +254,10 @@ Public Class frmGameManager mgrManifest.DoManifestUpdateByManifestID(oBackupItem, mgrSQLite.Database.Local) Next End If - - 'Remote - If mgrManifest.DoManifestCheck(oOriginalApp.ID, mgrSQLite.Database.Remote) Then - oBackupItems = mgrManifest.DoManifestGetByMonitorID(oOriginalApp.ID, mgrSQLite.Database.Remote) - - For Each oBackupItem As clsBackup In oBackupItems - 'Rename Current Backup File - sFileName = BackupFolder & oBackupItem.FileName - sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(sOriginalAppItem, sNewAppItem) - If File.Exists(sFileName) And Not sFileName = sNewFileName Then - FileSystem.Rename(sFileName, sNewFileName) - End If - - oBackupItem.MonitorID = oNewApp.ID - oBackupItem.FileName = oBackupItem.FileName.Replace(sOriginalAppItem, sNewAppItem) - mgrManifest.DoManifestUpdateByManifestID(oBackupItem, mgrSQLite.Database.Remote) - Next - - 'Rename folder if there is one - sDirectory = BackupFolder & sOriginalAppItem - sNewDirectory = sDirectory.Replace(sOriginalAppItem, sNewAppItem) - If Directory.Exists(sDirectory) And Not sDirectory = sNewDirectory Then - FileSystem.Rename(sDirectory, sNewDirectory) - End If - End If End If - End Sub + + Return True + End Function Private Sub LoadData(Optional ByVal bRetainFilter As Boolean = True) Dim oRestoreData As New SortedList @@ -1291,10 +1317,11 @@ Public Class frmGameManager End If Case eModes.Edit If CoreValidatation(oApp, False) Then - bSuccess = True - CheckManifestandUpdate(oCurrentGame, oApp, oSettings.UseGameID) - mgrMonitorList.DoListUpdate(oApp, CurrentGame.ID) - eCurrentMode = eModes.View + If CheckManifestandUpdate(oCurrentGame, oApp, oSettings.UseGameID) Then + bSuccess = True + mgrMonitorList.DoListUpdate(oApp, CurrentGame.ID) + eCurrentMode = eModes.View + End If End If Case eModes.MultiSelect Dim sMonitorIDs As New List(Of String) diff --git a/GBM/My Project/AssemblyInfo.vb b/GBM/My Project/AssemblyInfo.vb index 7de97fc..995cef7 100644 --- a/GBM/My Project/AssemblyInfo.vb +++ b/GBM/My Project/AssemblyInfo.vb @@ -33,7 +33,7 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + \ No newline at end of file diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index be66aa8..fe0c1b0 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -2013,6 +2013,24 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to The backup folder contains one or more backup files that cannot be renamed to [PARAM] because a file using that name already exist.[BR][BR]Do you want to continue and remove the existing files?. + ''' + Friend ReadOnly Property frmGameManager_ErrorRenameFilesExist() As String + Get + Return ResourceManager.GetString("frmGameManager_ErrorRenameFilesExist", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to The backup folder [PARAM] cannot be renamed to [PARAM] because a folder with that name already exists.[BR][BR]Do you want to continue and remove the existing folder?. + ''' + Friend ReadOnly Property frmGameManager_ErrorRenameFolderExists() As String + Get + Return ResourceManager.GetString("frmGameManager_ErrorRenameFolderExists", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to You must enter a valid game name.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index ad7b7c4..a33fa5c 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2197,4 +2197,10 @@ An error occured while extracting the executable icon. + + The backup folder contains one or more backup files that cannot be renamed to [PARAM] because a file using that name already exist.[BR][BR]Do you want to continue and remove the existing files? + + + The backup folder [PARAM] cannot be renamed to [PARAM] because a folder with that name already exists.[BR][BR]Do you want to continue and remove the existing folder? + \ No newline at end of file