Skip to content

Commit 9f29c9c

Browse files
committed
Fixed issues with Update.
1 parent a7201d7 commit 9f29c9c

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

Crowbar/Core/Updater/Updater.vb

+15-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Public Class Updater
2121
Public StatusMessage As String
2222
Public UpdateIsAvailable As Boolean
2323
Public DownloadIsEnabled As Boolean
24+
Public UpdateIsEnabled As Boolean
2425
End Class
2526

2627
Public Sub CheckForUpdate(ByVal given_ProgressChanged As ProgressChangedEventHandler, ByVal given_RunWorkerCompleted As RunWorkerCompletedEventHandler)
@@ -40,7 +41,6 @@ Public Class Updater
4041
Private Sub CheckForUpdate_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
4142
Dim bw As BackgroundWorkerEx = CType(sender, BackgroundWorkerEx)
4243

43-
Dim appVersion As Version = Nothing
4444
Dim fileSize As ULong = 0
4545

4646
'FROM: https://www.codeproject.com/Questions/1255767/Could-not-create-SSL-TLS-secure-channel
@@ -77,7 +77,7 @@ Public Class Updater
7777
Dim appNameVersion As String = CType(root("name"), String)
7878
'NOTE: Must append ".0.0" to version so that Version comparisons are correct.
7979
Dim appVersionText As String = appNameVersion.Replace("Crowbar ", "") + ".0.0"
80-
appVersion = New Version(appVersionText)
80+
Me.theAppVersion = New Version(appVersionText)
8181

8282
'Dim appVersionIsNewer As Boolean = appVersion > My.Application.Info.Version
8383
'Dim appVersionIsOlder As Boolean = appVersion < My.Application.Info.Version
@@ -103,22 +103,23 @@ Public Class Updater
103103
Dim outputInfo As New Updater.StatusOutputInfo()
104104
outputInfo.UpdateIsAvailable = False
105105
Dim updateCheckStatusMessage As String
106-
If appVersion Is Nothing Then
106+
If Me.theAppVersion Is Nothing Then
107107
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
109109
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) + " "
112112
outputInfo.UpdateIsAvailable = True
113113
Else
114114
'NOTE: Should not get here if versioning is done correctly.
115-
updateCheckStatusMessage = ""
115+
updateCheckStatusMessage = "Crowbar is up to date. "
116116
End If
117117
Dim now As DateTime = DateTime.Now()
118118
Dim lastCheckedMessage As String = "Last checked: " + now.ToLongDateString() + " " + now.ToShortTimeString()
119119

120120
outputInfo.StatusMessage = updateCheckStatusMessage + lastCheckedMessage
121121
outputInfo.DownloadIsEnabled = Me.theDownloadTaskIsEnabled
122+
outputInfo.UpdateIsEnabled = Me.theUpdateTaskIsEnabled
122123
e.Result = outputInfo
123124
End Try
124125
End Sub
@@ -145,6 +146,10 @@ Public Class Updater
145146
End Sub
146147

147148
Private Sub DownloadAfterCheckForUpdate()
149+
If Me.theUpdateTaskIsEnabled AndAlso Me.theAppVersion <= My.Application.Info.Version Then
150+
Exit Sub
151+
End If
152+
148153
Me.theLocalPathFileName = Path.Combine(Me.theLocalPath, Me.theLocalFileName)
149154
Me.theLocalPathFileName = FileManager.GetTestedPathFileName(Me.theLocalPathFileName)
150155

@@ -267,7 +272,7 @@ Public Class Updater
267272
#If DEBUG Then
268273
crowbarOrLauncherExeProcess.StartInfo.CreateNoWindow = False
269274
#Else
270-
lzmaExeProcess.StartInfo.CreateNoWindow = True
275+
crowbarOrLauncherExeProcess.StartInfo.CreateNoWindow = True
271276
#End If
272277
crowbarOrLauncherExeProcess.Start()
273278
Application.Exit()
@@ -329,6 +334,8 @@ Public Class Updater
329334
Private theUpdateRunWorkerCompletedHandler As RunWorkerCompletedEventHandler
330335
Private theUpdateTaskIsEnabled As Boolean
331336

337+
Private theAppVersion As Version = Nothing
338+
332339
#End Region
333340

334341
End Class

Crowbar/Resources/CrowbarLauncher.exe

-512 Bytes
Binary file not shown.

Crowbar/Widgets/Main Tabs/UpdateUserControl.vb

+6-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ Public Class UpdateUserControl
135135
Me.CheckForUpdateTextBox.Text = CType(outputInfo.StatusMessage, String)
136136
NotifyUpdateAvailable(outputInfo.UpdateIsAvailable)
137137

138-
If outputInfo.DownloadIsEnabled Then
138+
If outputInfo.UpdateIsEnabled AndAlso Not outputInfo.UpdateIsAvailable Then
139+
Me.theCurrentProgressBar.Text = "No available update."
140+
Me.theCurrentProgressBar.Value = 0
141+
ElseIf outputInfo.DownloadIsEnabled AndAlso Not (outputInfo.UpdateIsEnabled AndAlso Not outputInfo.UpdateIsAvailable) Then
139142
Me.theCurrentProgressBar.Text = "Starting download..."
140143
Me.theCurrentProgressBar.Value = 0
141144
End If
@@ -159,12 +162,12 @@ Public Class UpdateUserControl
159162
Try
160163
File.Delete(pathFileName)
161164
Catch ex As Exception
162-
Me.theCurrentProgressBar.Text += "WARNING: Problem deleting incomplete downloaded file: """ + pathFileName + """"
165+
Me.theCurrentProgressBar.Text += "WARNING: Problem deleting incomplete downloaded file: """ + Path.GetFileName(pathFileName) + """"
163166
End Try
164167
End If
165168
Else
166169
If File.Exists(pathFileName) Then
167-
Me.theCurrentProgressBar.Text = "Download complete. Downloaded file: """ + pathFileName + """" + Me.theCurrentProgressBar.Text
170+
Me.theCurrentProgressBar.Text = "Downloaded file: """ + Path.GetFileName(pathFileName) + """ " + Me.theCurrentProgressBar.Text
168171
Me.GotoDownloadFileButton.Enabled = True
169172
Me.theDownloadedPathFileName = pathFileName
170173
Else

0 commit comments

Comments
 (0)