Skip to content

Commit

Permalink
Merge pull request #24 from limosoft-de/development
Browse files Browse the repository at this point in the history
Version 2.2.3
  • Loading branch information
limosoft-de committed Aug 19, 2020
2 parents 3b5f722 + 15a6d4b commit 676714c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
1 change: 1 addition & 0 deletions Raffy Timelapse Updater/Raffy Timelapse Updater.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>RaffyUpdater.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
Expand Down
36 changes: 21 additions & 15 deletions Raffy Timelapse Updater/form_main.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 22 additions & 14 deletions Raffy Timelapse Updater/form_main.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ Public Class form_main

Dim DownloadVersion As Version
Dim NetcheckURL As String = "sourceforge.net"
Dim UpdaterURL As String = "https://simpletimelapse.sourceforge.io/update/updateURL.txt"
Dim DownloadURL As String = ""
Dim UpdaterPath As String = Application.UserAppDataPath & "\RaffyInstaller.msi"
Dim ConfigURL As String = "https://simpletimelapse.sourceforge.io/update/update.xml"
Dim DownloadURL As String = "" 'will be overridden by GetUpdateValues()
Dim UpdaterPath As String = Application.UserAppDataPath & "\RaffyInstaller"
Dim UpdaterExtension As String = ".msi" 'will be overridden by GetUpdateValues()
Dim UpdaterStarted As Boolean = False

#Region "Form Events"
Expand Down Expand Up @@ -36,7 +37,11 @@ Public Class form_main
End If

Lbl_Status.Text = "Locating update server..."
DownloadURL = GetUpdaterURL()
If GetUpdateValues() = False Then
MessageBox.Show("Can't establish connection to the configuration server, please try again later. Raffy Timelapse Updater will close now.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Close()
Exit Sub
End If

Lbl_Status.Text = "Downloading update package..."
DownloadStart()
Expand All @@ -57,16 +62,19 @@ Public Class form_main
End Function
#End Region

#Region "UpdaterURL"
Public Function GetUpdaterURL() As String
#Region "GetUpdateValues"
Public Function GetUpdateValues() As Boolean

Try
Dim updateXml As XDocument = XDocument.Load(ConfigURL & "?Refresh=" & Guid.NewGuid().ToString()) 'USING GUID PARAMETER TO AVOID IE CACHING
DownloadURL = updateXml.Root.Element("url").Value
UpdaterExtension = updateXml.Root.Element("extension").Value

Dim UpdaterBrowser As New WebBrowser
UpdaterBrowser.Navigate(UpdaterURL & "?Refresh=" & Guid.NewGuid().ToString()) 'USING GUID PARAMETER TO AVOID IE CACHING
Do Until UpdaterBrowser.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop
Return True

Return UpdaterBrowser.Document.Body.InnerText
Catch ex As Exception
Return False
End Try

End Function
#End Region
Expand All @@ -75,7 +83,7 @@ Public Class form_main
Public WithEvents Downloader As WebClient
Public Sub DownloadStart()
Downloader = New WebClient
Downloader.DownloadFileAsync(New Uri(DownloadURL), UpdaterPath)
Downloader.DownloadFileAsync(New Uri(DownloadURL), UpdaterPath & UpdaterExtension)
End Sub

Private Sub downloader_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles downloader.DownloadProgressChanged
Expand All @@ -95,7 +103,7 @@ Public Class form_main
If UpdaterStarted = False Then

UpdaterStarted = True
Process.Start(UpdaterPath)
Process.Start(UpdaterPath & UpdaterExtension)
Close()

End If
Expand Down

0 comments on commit 676714c

Please sign in to comment.