From 0b7d382f0f2c9023f0f0786640da5dc472997da9 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Wed, 27 Feb 2019 19:02:31 -0600 Subject: [PATCH] Fix #180 --- GBM/Managers/mgrBackup.vb | 55 ++++++++++++++++------------ GBM/Managers/mgrCommon.vb | 4 +- GBM/Managers/mgrPath.vb | 6 +++ GBM/My Project/Resources.Designer.vb | 9 +++++ GBM/My Project/Resources.resx | 3 ++ 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb index fcfeff9..fd52f59 100644 --- a/GBM/Managers/mgrBackup.vb +++ b/GBM/Managers/mgrBackup.vb @@ -127,32 +127,39 @@ Public Class mgrBackup 'Verify saved game path sSavePath = VerifySavePath(oGame) - 'Calculate space - lAvailableSpace = mgrCommon.GetAvailableDiskSpace(oSettings.BackupFolder) - 'If any includes are using a deep path and we aren't using recursion, we need to go directly to folders to do file size calculations or they will be missed. - If Not oGame.RecurseSubFolders Then - For Each s As String In oGame.IncludeArray - If s.Contains(Path.DirectorySeparatorChar) Then - sDeepFolder = Path.GetDirectoryName(sSavePath & Path.DirectorySeparatorChar & s) - If Directory.Exists(sDeepFolder) Then - lFolderSize += mgrCommon.GetFolderSize(sDeepFolder, oGame.IncludeArray, oGame.ExcludeArray, oGame.RecurseSubFolders) + 'When the backup folder is using a UNC path, skip the disk space check because we can't do it properly. + If Not mgrPath.IsPathUNC(oSettings.BackupFolder) Then + 'Calculate space + lAvailableSpace = mgrCommon.GetAvailableDiskSpace(oSettings.BackupFolder) + + 'If any includes are using a deep path and we aren't using recursion, we need to go directly to folders to do file size calculations or they will be missed. + If Not oGame.RecurseSubFolders Then + For Each s As String In oGame.IncludeArray + If s.Contains(Path.DirectorySeparatorChar) Then + sDeepFolder = Path.GetDirectoryName(sSavePath & Path.DirectorySeparatorChar & s) + If Directory.Exists(sDeepFolder) Then + lFolderSize += mgrCommon.GetFolderSize(sDeepFolder, oGame.IncludeArray, oGame.ExcludeArray, oGame.RecurseSubFolders) + End If End If - End If - Next - End If - lFolderSize += mgrCommon.GetFolderSize(sSavePath, oGame.IncludeArray, oGame.ExcludeArray, oGame.RecurseSubFolders) - - 'Show Available Space - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_AvailableDiskSpace, mgrCommon.FormatDiskSpace(lAvailableSpace)), False, ToolTipIcon.Info, True) - - 'Show Save Folder Size - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_SavedGameFolderSize, New String() {oGame.Name, mgrCommon.FormatDiskSpace(lFolderSize)}), False, ToolTipIcon.Info, True) - - If lFolderSize >= lAvailableSpace Then - If mgrCommon.ShowMessage(mgrBackup_ConfirmDiskSpace, MsgBoxStyle.YesNo) = MsgBoxResult.No Then - RaiseEvent UpdateLog(mgrBackup_ErrorDiskSpace, False, ToolTipIcon.Error, True) - Return False + Next End If + lFolderSize += mgrCommon.GetFolderSize(sSavePath, oGame.IncludeArray, oGame.ExcludeArray, oGame.RecurseSubFolders) + + 'Show Available Space + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_AvailableDiskSpace, mgrCommon.FormatDiskSpace(lAvailableSpace)), False, ToolTipIcon.Info, True) + + 'Show Save Folder Size + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_SavedGameFolderSize, New String() {oGame.Name, mgrCommon.FormatDiskSpace(lFolderSize)}), False, ToolTipIcon.Info, True) + + If lFolderSize >= lAvailableSpace Then + If mgrCommon.ShowMessage(mgrBackup_ConfirmDiskSpace, MsgBoxStyle.YesNo) = MsgBoxResult.No Then + RaiseEvent UpdateLog(mgrBackup_ErrorDiskSpace, False, ToolTipIcon.Error, True) + Return False + End If + End If + Else + 'Show that disk space check was skipped + RaiseEvent UpdateLog(mgrBackup_ErrorBackupPathIsUNC, False, ToolTipIcon.Info, True) End If 'A manifest check is only required when "Save Multiple Backups" is disabled diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index 6e0baf2..3981578 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -117,9 +117,9 @@ Public Class mgrCommon End If Return fbBrowser.FileName - End If + End If - Return String.Empty + Return String.Empty End Function Private Shared Function BuildFileBrowser(ByVal sName As String, ByVal sTitle As String, ByVal sExtension As String, ByVal sFileType As String, ByVal sDefaultFolder As String, diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index bee4047..b70556f 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -484,6 +484,12 @@ Public Class mgrPath Return sValue End Function + Public Shared Function IsPathUNC(sPath As String) As Boolean + Dim sPrefix As String = Path.DirectorySeparatorChar & Path.DirectorySeparatorChar + If sPath.StartsWith(sPrefix) Then Return True + Return False + End Function + Public Shared Function IsAbsolute(sValue As String) As Boolean Dim hshFolders As New Hashtable Dim hshCustomVariables As Hashtable = mgrVariables.ReadVariables diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 317c9f6..5b0a353 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -6006,6 +6006,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to The backup folder is a UNC path. The disk space check has been skipped.. + ''' + Friend ReadOnly Property mgrBackup_ErrorBackupPathIsUNC() As String + Get + Return ResourceManager.GetString("mgrBackup_ErrorBackupPathIsUNC", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Backup aborted due to lack of disk space.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index b3f8eaf..0e28fb3 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2335,4 +2335,7 @@ An error occured attempting to launch the application:[BR][BR][PARAM] + + The backup folder is a UNC path. The disk space check has been skipped. + \ No newline at end of file