Sub Download_Update(u As String)
Dim j2 As HttpJob
j2.Initialize("", Me)
j2.Download(u)
Wait For (j2) JobDone(j2 As HttpJob)
Dim Allow As Int
If j2.Success Then
'Log(j2.GetString)
If j2.GetString = "Wrong password !" Then
j2.Release
ToastMessageShow(j2.GetString, True)
CallSubDelayed(Me, "Activity_Resume")
Return
End If
Log(j2.Response.GetHeaders) 'HERE CORRECT FILE SIZE !
Allow = 1
Starter.SQL.Close
File.Delete(others.Folder, Starter.dbName)
Dim out As OutputStream = File.OpenOutput(others.Folder, Starter.dbName, False)
Wait For (File.Copy2Async(j2.GetInputStream, out)) Complete (Success As Boolean)
Log("Success: " & Success)
If Success Then
Log(File.Size(others.Folder, Starter.dbName)) 'HERE SMALLER SIZE THAN MUST BE
Allow = 1
StopService(Starter)
Sleep(10)
StartService(Starter)
Sleep(10)
Else
Allow = 2 'error
End If
Else
Allow = 2 'error
End If
If Allow = 0 Then
Msgbox("No update", "Нет:")
Else If Allow = 1 Then
Msgbox("Updated OK !", "ОК:")
Else
Msgbox("Update error.", "Try later:")
End If
j2.Release
Activity.Finish
End Sub