@@ -21,6 +21,7 @@ Public Class Updater
21
21
Public StatusMessage As String
22
22
Public UpdateIsAvailable As Boolean
23
23
Public DownloadIsEnabled As Boolean
24
+ Public UpdateIsEnabled As Boolean
24
25
End Class
25
26
26
27
Public Sub CheckForUpdate( ByVal given_ProgressChanged As ProgressChangedEventHandler, ByVal given_RunWorkerCompleted As RunWorkerCompletedEventHandler)
@@ -40,7 +41,6 @@ Public Class Updater
40
41
Private Sub CheckForUpdate_DoWork( ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
41
42
Dim bw As BackgroundWorkerEx = CType (sender, BackgroundWorkerEx)
42
43
43
- Dim appVersion As Version = Nothing
44
44
Dim fileSize As ULong = 0
45
45
46
46
'FROM: https://www.codeproject.com/Questions/1255767/Could-not-create-SSL-TLS-secure-channel
@@ -77,7 +77,7 @@ Public Class Updater
77
77
Dim appNameVersion As String = CType (root( "name" ), String )
78
78
'NOTE: Must append ".0.0" to version so that Version comparisons are correct.
79
79
Dim appVersionText As String = appNameVersion.Replace( "Crowbar " , "" ) + ".0.0"
80
- appVersion = New Version(appVersionText)
80
+ Me .theAppVersion = New Version(appVersionText)
81
81
82
82
'Dim appVersionIsNewer As Boolean = appVersion > My.Application.Info.Version
83
83
'Dim appVersionIsOlder As Boolean = appVersion < My.Application.Info.Version
@@ -103,22 +103,23 @@ Public Class Updater
103
103
Dim outputInfo As New Updater.StatusOutputInfo()
104
104
outputInfo.UpdateIsAvailable = False
105
105
Dim updateCheckStatusMessage As String
106
- If appVersion Is Nothing Then
106
+ If Me .theAppVersion Is Nothing Then
107
107
updateCheckStatusMessage = "Unable to get update info. Please try again later. "
108
- ElseIf appVersion = My.Application.Info.Version Then
108
+ ElseIf Me .theAppVersion = My.Application.Info.Version Then
109
109
updateCheckStatusMessage = "Crowbar is up to date. "
110
- ElseIf appVersion > My.Application.Info.Version Then
111
- updateCheckStatusMessage = "Update to version " + appVersion .ToString(2 ) + " available. Size: " + MathModule.ByteUnitsConversion(fileSize) + " "
110
+ ElseIf Me .theAppVersion > My.Application.Info.Version Then
111
+ updateCheckStatusMessage = "Update to version " + Me .theAppVersion .ToString(2 ) + " available. Size: " + MathModule.ByteUnitsConversion(fileSize) + " "
112
112
outputInfo.UpdateIsAvailable = True
113
113
Else
114
114
'NOTE: Should not get here if versioning is done correctly.
115
- updateCheckStatusMessage = ""
115
+ updateCheckStatusMessage = "Crowbar is up to date. "
116
116
End If
117
117
Dim now As DateTime = DateTime.Now()
118
118
Dim lastCheckedMessage As String = "Last checked: " + now.ToLongDateString() + " " + now.ToShortTimeString()
119
119
120
120
outputInfo.StatusMessage = updateCheckStatusMessage + lastCheckedMessage
121
121
outputInfo.DownloadIsEnabled = Me .theDownloadTaskIsEnabled
122
+ outputInfo.UpdateIsEnabled = Me .theUpdateTaskIsEnabled
122
123
e.Result = outputInfo
123
124
End Try
124
125
End Sub
@@ -145,6 +146,10 @@ Public Class Updater
145
146
End Sub
146
147
147
148
Private Sub DownloadAfterCheckForUpdate()
149
+ If Me .theUpdateTaskIsEnabled AndAlso Me .theAppVersion <= My.Application.Info.Version Then
150
+ Exit Sub
151
+ End If
152
+
148
153
Me .theLocalPathFileName = Path.Combine( Me .theLocalPath, Me .theLocalFileName)
149
154
Me .theLocalPathFileName = FileManager.GetTestedPathFileName( Me .theLocalPathFileName)
150
155
@@ -267,7 +272,7 @@ Public Class Updater
267
272
# If DEBUG Then
268
273
crowbarOrLauncherExeProcess.StartInfo.CreateNoWindow = False
269
274
# Else
270
- lzmaExeProcess .StartInfo.CreateNoWindow = True
275
+ crowbarOrLauncherExeProcess .StartInfo.CreateNoWindow = True
271
276
# End If
272
277
crowbarOrLauncherExeProcess.Start()
273
278
Application.Exit()
@@ -329,6 +334,8 @@ Public Class Updater
329
334
Private theUpdateRunWorkerCompletedHandler As RunWorkerCompletedEventHandler
330
335
Private theUpdateTaskIsEnabled As Boolean
331
336
337
+ Private theAppVersion As Version = Nothing
338
+
332
339
# End Region
333
340
334
341
End Class
0 commit comments