Some fixes for backup size calculations

This commit is contained in:
Michael J. Seiferling
2018-10-17 10:32:52 -06:00
parent 9fdc35c43d
commit f204f6ccc6
2 changed files with 19 additions and 5 deletions
+14 -2
View File
@@ -118,7 +118,8 @@ Public Class mgrBackup
Dim sSavePath As String Dim sSavePath As String
Dim sOverwriteMessage As String Dim sOverwriteMessage As String
Dim lAvailableSpace As Long Dim lAvailableSpace As Long
Dim lFolderSize As Long Dim lFolderSize As Long = 0
Dim sDeepFolder As String
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & ".7z" sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & ".7z"
@@ -128,7 +129,18 @@ Public Class mgrBackup
'Calculate space 'Calculate space
lAvailableSpace = mgrCommon.GetAvailableDiskSpace(oSettings.BackupFolder) lAvailableSpace = mgrCommon.GetAvailableDiskSpace(oSettings.BackupFolder)
lFolderSize = mgrCommon.GetFolderSize(sSavePath, oGame.IncludeArray, oGame.ExcludeArray, oGame.RecurseSubFolders) '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
Next
End If
lFolderSize += mgrCommon.GetFolderSize(sSavePath, oGame.IncludeArray, oGame.ExcludeArray, oGame.RecurseSubFolders)
'Show Available Space 'Show Available Space
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_AvailableDiskSpace, mgrCommon.FormatDiskSpace(lAvailableSpace)), False, ToolTipIcon.Info, True) RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_AvailableDiskSpace, mgrCommon.FormatDiskSpace(lAvailableSpace)), False, ToolTipIcon.Info, True)
+5 -3
View File
@@ -293,14 +293,15 @@ Public Class mgrCommon
Public Shared Function WildcardToRegex(ByVal sPattern As String) As String Public Shared Function WildcardToRegex(ByVal sPattern As String) As String
Dim sRegEx As String Dim sRegEx As String
sRegEx = sPattern.Replace("*", ".*") sPattern = Regex.Escape(sPattern)
sRegEx = sRegEx.Replace("?", ".") sRegEx = sPattern.Replace("\*", ".*")
sRegEx = sRegEx.Replace("\?", ".")
Return sRegEx Return sRegEx
End Function End Function
Public Shared Function CompareValueToArrayRegEx(ByVal sValue As String, ByVal sValues As String()) As Boolean Public Shared Function CompareValueToArrayRegEx(ByVal sValue As String, ByVal sValues As String()) As Boolean
For Each se As String In sValues For Each se As String In sValues
If Regex.IsMatch(sValue, Regex.Escape(WildcardToRegex(se))) Then If Regex.IsMatch(sValue, WildcardToRegex(se)) Then
Return True Return True
End If End If
Next Next
@@ -331,6 +332,7 @@ Public Class mgrCommon
'Files 'Files
For Each fi As FileInfo In oFolder.EnumerateFiles() For Each fi As FileInfo In oFolder.EnumerateFiles()
If sInclude.Length > 0 Then If sInclude.Length > 0 Then
bInclude = CompareValueToArrayRegEx(fi.FullName, sInclude) bInclude = CompareValueToArrayRegEx(fi.FullName, sInclude)
Else Else