Added new 7z functionality

This commit is contained in:
Michael J. Seiferling
2016-05-23 09:20:18 -06:00
parent 0e4f357c01
commit 3acb790822
8 changed files with 136 additions and 36 deletions
+14 -7
View File
@@ -811,13 +811,6 @@ Public Class frmMain
Private Sub LoadAndVerify() Private Sub LoadAndVerify()
'The application cannot continue if this fails
If Not oBackup.CheckForUtilities(mgrPath.Utility7zLocation) Then
mgrCommon.ShowMessage(frmMain_Error7zip, MsgBoxStyle.Critical)
bShutdown = True
Me.Close()
End If
'Local Database Check 'Local Database Check
VerifyDBVersion(mgrSQLite.Database.Local) VerifyDBVersion(mgrSQLite.Database.Local)
LocalDatabaseCheck() LocalDatabaseCheck()
@@ -855,6 +848,20 @@ Public Class frmMain
End If End If
End If End If
'Check for any custom 7z utility and display a warning if it's missing
If oSettings.Custom7zLocation <> String.Empty Then
If Not oBackup.CheckForUtilities(oSettings.Custom7zLocation) Then
mgrCommon.ShowMessage(frmMain_Error7zCustom, oSettings.Custom7zLocation, MsgBoxStyle.Exclamation)
End If
End If
'If the default utility is missing we cannot continue
If Not oBackup.CheckForUtilities(mgrPath.Default7zLocation) Then
mgrCommon.ShowMessage(frmMain_Error7zip, MsgBoxStyle.Critical)
bShutdown = True
Me.Close()
End If
End Sub End Sub
'Functions that handle buttons, menus and other GUI features on this form 'Functions that handle buttons, menus and other GUI features on this form
+31 -8
View File
@@ -1,4 +1,5 @@
Imports GBM.My.Resources Imports GBM.My.Resources
Imports System.IO
Public Class frmSettings Public Class frmSettings
Dim bShutdown As Boolean = False Dim bShutdown As Boolean = False
@@ -83,10 +84,13 @@ Public Class frmSettings
oSettings.SupressBackup = chkSupressBackup.Checked oSettings.SupressBackup = chkSupressBackup.Checked
oSettings.SupressBackupThreshold = nudSupressBackupThreshold.Value oSettings.SupressBackupThreshold = nudSupressBackupThreshold.Value
oSettings.CompressionLevel = cboCompression.SelectedValue oSettings.CompressionLevel = cboCompression.SelectedValue
oSettings.Custom7zArguments = txt7zArguments.Text
'TODO: Add Custom Location Validation! If oSettings.Custom7zArguments <> txt7zArguments.Text.Trim And txt7zArguments.Text.Trim <> String.Empty Then
oSettings.Custom7zLocation = txt7zLocation.Text mgrCommon.ShowMessage(frmSettings_WarningArguments, MsgBoxStyle.Exclamation)
End If
oSettings.Custom7zArguments = txt7zArguments.Text.Trim
oSettings.Custom7zLocation = txt7zLocation.Text.Trim
'We need to clear all checksums its turned off 'We need to clear all checksums its turned off
If chkCheckSum.Checked = False And oSettings.CheckSum = True Then If chkCheckSum.Checked = False And oSettings.CheckSum = True Then
@@ -105,7 +109,7 @@ Public Class frmSettings
oSettings.SyncTags = chkSyncTags.Checked oSettings.SyncTags = chkSyncTags.Checked
oSettings.SyncAll = chkSyncAll.Checked oSettings.SyncAll = chkSyncAll.Checked
If IO.Directory.Exists(txtBackupFolder.Text) Then If Directory.Exists(txtBackupFolder.Text) Then
If oSettings.BackupFolder <> txtBackupFolder.Text Then If oSettings.BackupFolder <> txtBackupFolder.Text Then
If chkSync.Checked Then bBackupLocationChanged = True If chkSync.Checked Then bBackupLocationChanged = True
End If End If
@@ -115,8 +119,15 @@ Public Class frmSettings
Return False Return False
End If End If
If oSettings.Custom7zArguments <> String.Empty Then If oSettings.Custom7zLocation <> String.Empty Then
mgrCommon.ShowMessage(frmSettings_WarningArguments, MsgBoxStyle.Exclamation) If File.Exists(oSettings.Custom7zLocation) Then
If Path.GetFileNameWithoutExtension(oSettings.Custom7zLocation) <> "7za" Then
mgrCommon.ShowMessage(frmSettings_WarningLocation, MsgBoxStyle.Exclamation)
End If
Else
mgrCommon.ShowMessage(frmSettings_ErrorLocation, oSettings.Custom7zLocation, MsgBoxStyle.Critical)
Return False
End If
End If End If
Return True Return True
@@ -137,7 +148,7 @@ Public Class frmSettings
Try Try
'Use default when no custom location is set 'Use default when no custom location is set
If sLocation = String.Empty Then If sLocation = String.Empty Then
sLocation = mgrPath.Utility7zLocation sLocation = mgrPath.Default7zLocation
End If End If
'Get info 'Get info
@@ -146,9 +157,17 @@ Public Class frmSettings
lbl7zCopyright.Text = oFileInfo.LegalCopyright lbl7zCopyright.Text = oFileInfo.LegalCopyright
Catch ex As Exception Catch ex As Exception
lbl7zProduct.Text = mgrCommon.FormatString(frmSettings_Error7zInfo) lbl7zProduct.Text = mgrCommon.FormatString(frmSettings_Error7zInfo)
lbl7zCopyright.Text = String.Empty
End Try End Try
End Sub End Sub
Private Sub SetDefaults()
If mgrCommon.ShowMessage(frmSettings_ConfirmDefaults, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
oSettings = New mgrSettings
LoadSettings()
End If
End Sub
Private Sub LoadSettings() Private Sub LoadSettings()
chkStartWindows.Checked = oSettings.StartWithWindows chkStartWindows.Checked = oSettings.StartWithWindows
chkMonitorOnStartup.Checked = oSettings.MonitorOnStartup chkMonitorOnStartup.Checked = oSettings.MonitorOnStartup
@@ -298,6 +317,10 @@ Public Class frmSettings
End Sub End Sub
Private Sub txt7zLocation_Leave(sender As Object, e As EventArgs) Handles txt7zLocation.Leave Private Sub txt7zLocation_Leave(sender As Object, e As EventArgs) Handles txt7zLocation.Leave
Get7zInfo(txt7zLocation.Text) Get7zInfo(txt7zLocation.Text.Trim)
End Sub
Private Sub btnDefaults_Click(sender As Object, e As EventArgs) Handles btnDefaults.Click
SetDefaults()
End Sub End Sub
End Class End Class
+3 -8
View File
@@ -169,20 +169,15 @@ Public Class mgrBackup
BuildFileList(sSavePath, oGame.ExcludeList, mgrPath.ExcludeFileLocation) BuildFileList(sSavePath, oGame.ExcludeList, mgrPath.ExcludeFileLocation)
Try Try
If Directory.Exists(sSavePath) Then
'Need to delete any prior archive if it exists, the 7za utility does not support overwriting or deleting existing archives. 'Need to delete any prior archive if it exists, the 7za utility does not support overwriting or deleting existing archives.
'If we let 7za update existing archives it will lead to excessive bloat with games that routinely add and remove files with many different file names. 'If we let 7za update existing archives it will lead to excessive bloat with games that routinely add and remove files with many different file names.
If File.Exists(sBackupFile) Then If File.Exists(sBackupFile) Then
File.Delete(sBackupFile) File.Delete(sBackupFile)
End If End If
If Directory.Exists(sSavePath) Then prs7z.StartInfo.Arguments = "a" & oSettings.Prepared7zArguments & "-t7z -mx" & oSettings.CompressionLevel & " -i@""" & mgrPath.IncludeFileLocation & """ -x@""" & mgrPath.ExcludeFileLocation & """ """ & sBackupFile & """ -r"
'The Linux version of 7za doesn't support the new verbose parameters and fails out. Just split this up for now until we have a better solution. prs7z.StartInfo.FileName = oSettings.Utility7zLocation
If mgrCommon.IsUnix Then
prs7z.StartInfo.Arguments = "a -t7z -mx" & oSettings.CompressionLevel & " -i@""" & mgrPath.IncludeFileLocation & """ -x@""" & mgrPath.ExcludeFileLocation & """ """ & sBackupFile & """ -r"
Else
prs7z.StartInfo.Arguments = "a -bb1 -bt -t7z -mx" & oSettings.CompressionLevel & " -i@""" & mgrPath.IncludeFileLocation & """ -x@""" & mgrPath.ExcludeFileLocation & """ """ & sBackupFile & """ -r"
End If
prs7z.StartInfo.FileName = mgrPath.Utility7zLocation
prs7z.StartInfo.UseShellExecute = False prs7z.StartInfo.UseShellExecute = False
prs7z.StartInfo.RedirectStandardOutput = True prs7z.StartInfo.RedirectStandardOutput = True
prs7z.StartInfo.CreateNoWindow = True prs7z.StartInfo.CreateNoWindow = True
+1 -1
View File
@@ -37,7 +37,7 @@ Public Class mgrPath
End Get End Get
End Property End Property
Shared ReadOnly Property Utility7zLocation As String Shared ReadOnly Property Default7zLocation As String
Get Get
If mgrCommon.IsUnix Then If mgrCommon.IsUnix Then
Return "/usr/bin/7za" Return "/usr/bin/7za"
+2 -6
View File
@@ -231,12 +231,8 @@ Public Class mgrRestore
Try Try
If File.Exists(sBackupFile) Then If File.Exists(sBackupFile) Then
If mgrCommon.IsUnix Then prs7z.StartInfo.Arguments = "x" & oSettings.Prepared7zArguments & """" & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r"
prs7z.StartInfo.Arguments = "x """ & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r" prs7z.StartInfo.FileName = oSettings.Utility7zLocation
Else
prs7z.StartInfo.Arguments = "x -bb1 -bt """ & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r"
End If
prs7z.StartInfo.FileName = mgrPath.Utility7zLocation
prs7z.StartInfo.UseShellExecute = False prs7z.StartInfo.UseShellExecute = False
prs7z.StartInfo.RedirectStandardOutput = True prs7z.StartInfo.RedirectStandardOutput = True
prs7z.StartInfo.CreateNoWindow = True prs7z.StartInfo.CreateNoWindow = True
+31
View File
@@ -204,6 +204,21 @@ Public Class mgrSettings
End Set End Set
End Property End Property
ReadOnly Property Prepared7zArguments As String
Get
'Prepare custom 7z arguments
Dim sPreparedArguments As String
If s7zArguments <> String.Empty Then
'Surround the arguments with spaces to be inserted into command
sPreparedArguments = " " & s7zArguments & " "
Else
'The command always needs at least one space inserted
sPreparedArguments = " "
End If
Return sPreparedArguments
End Get
End Property
Property Custom7zLocation As String Property Custom7zLocation As String
Get Get
Return s7zLocation Return s7zLocation
@@ -213,6 +228,22 @@ Public Class mgrSettings
End Set End Set
End Property End Property
ReadOnly Property Utility7zLocation As String
Get
'Return default utility when custom setting is not used
If s7zLocation = String.Empty Then
Return mgrPath.Default7zLocation
Else
'Check if custom utility is available, if not use the default utility
If File.Exists(s7zLocation) Then
Return s7zLocation
Else
Return mgrPath.Default7zLocation
End If
End If
End Get
End Property
Property BackupFolder As String Property BackupFolder As String
Get Get
Return sBackupFolder Return sBackupFolder
+37 -1
View File
@@ -2310,6 +2310,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to The custom 7-Zip utility could not be found at:[BR][BR][PARAM][BR][BR]Please check your settings, the default 7-Zip utility will be used..
'''</summary>
Friend ReadOnly Property frmMain_Error7zCustom() As String
Get
Return ResourceManager.GetString("frmMain_Error7zCustom", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to 7-Zip was not found. The application cannot continue.. ''' Looks up a localized string similar to 7-Zip was not found. The application cannot continue..
'''</summary> '''</summary>
@@ -3327,6 +3336,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to Do you want to revert all settings to their defaults?.
'''</summary>
Friend ReadOnly Property frmSettings_ConfirmDefaults() As String
Get
Return ResourceManager.GetString("frmSettings_ConfirmDefaults", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to Unable to retrieve 7z product information!. ''' Looks up a localized string similar to Unable to retrieve 7z product information!.
'''</summary> '''</summary>
@@ -3345,6 +3363,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to The custom 7-Zip location [PARAM] does not exist..
'''</summary>
Friend ReadOnly Property frmSettings_ErrorLocation() As String
Get
Return ResourceManager.GetString("frmSettings_ErrorLocation", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to Settings. ''' Looks up a localized string similar to Settings.
'''</summary> '''</summary>
@@ -3454,7 +3481,7 @@ Namespace My.Resources
End Property End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to Custom 7-Zip arguments can cause backup or restore operations to fail.[BR][BR]If problems occur, clear the arguments and refer to the GBM manual.. ''' Looks up a localized string similar to Invalid or poorly formatted 7-Zip arguments can cause backup or restore operations to fail.[BR][BR]If problems occur, clear the arguments and refer to the GBM manual..
'''</summary> '''</summary>
Friend ReadOnly Property frmSettings_WarningArguments() As String Friend ReadOnly Property frmSettings_WarningArguments() As String
Get Get
@@ -3462,6 +3489,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to You have chosen a custom utility that does not appear to be 7-Zip Console (7za). GBM only supports the use of 7-Zip..
'''</summary>
Friend ReadOnly Property frmSettings_WarningLocation() As String
Get
Return ResourceManager.GetString("frmSettings_WarningLocation", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to Choose a backup folder:. ''' Looks up a localized string similar to Choose a backup folder:.
'''</summary> '''</summary>
+13 -1
View File
@@ -1637,6 +1637,18 @@
<value>Locate 7-Zip Console (7za)</value> <value>Locate 7-Zip Console (7za)</value>
</data> </data>
<data name="frmSettings_WarningArguments" xml:space="preserve"> <data name="frmSettings_WarningArguments" xml:space="preserve">
<value>Custom 7-Zip arguments can cause backup or restore operations to fail.[BR][BR]If problems occur, clear the arguments and refer to the GBM manual.</value> <value>Invalid or poorly formatted 7-Zip arguments can cause backup or restore operations to fail.[BR][BR]If problems occur, clear the arguments and refer to the GBM manual.</value>
</data>
<data name="frmMain_Error7zCustom" xml:space="preserve">
<value>The custom 7-Zip utility could not be found at:[BR][BR][PARAM][BR][BR]Please check your settings, the default 7-Zip utility will be used.</value>
</data>
<data name="frmSettings_ConfirmDefaults" xml:space="preserve">
<value>Do you want to revert all settings to their defaults?</value>
</data>
<data name="frmSettings_ErrorLocation" xml:space="preserve">
<value>The custom 7-Zip location [PARAM] does not exist.</value>
</data>
<data name="frmSettings_WarningLocation" xml:space="preserve">
<value>You have chosen a custom utility that does not appear to be 7-Zip Console (7za). GBM only supports the use of 7-Zip.</value>
</data> </data>
</root> </root>