Kaju self-updater talk

  1. ‹ Older
  2. last week

    Kem T

    Feb 16 Pre-Release Testers, Xojo Pro New York

    No, no idea.

  3. I worked it out. It was a date format issue and region settings that cause the date set in the Windows shell script to come out weird and include a "/" also. I've changed the script to use this code instead:

    @SETLOCAL ENABLEDELAYEDEXPANSION
    
    @REM Use WMIC to retrieve date and time
    
    FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
        IF NOT "%%~F"=="" (
            SET /A SortDate = 10000 * %%F + 100 * %%D + %%A
            set YEAR=!SortDate:~0,4!
            set MON=!SortDate:~4,2!
            set DAY=!SortDate:~6,2!
            @REM Add 1000000 so as to force a prepended 0 if hours less than 10
            SET /A SortTime = 1000000 + 10000 * %%B + 100 * %%C + %%E
            set HOUR=!SortTime:~1,2!
            set MIN=!SortTime:~3,2!
            set SEC=!SortTime:~5,2!
        )
    )
    
    REM -----------------
    
    SET TODAY_DATE=%YEAR%-%MON%-%DAY% %HOUR%:%MIN%:%SEC%
    SET DATE_CODE=%YEAR%%MON%%DAY%%HOUR%%MIN%%SEC%
    
    SET APP_PATH=%APP_PARENT%\%APP_NAME%
    
    SET BACKUP_PARENT=%APP_PATH%-%DATE_CODE%

    Log looks like: "STARTED ON 2017-02-17 12:39:33"
    Backup folder name looks like: "KajuUpdater.exe-20170217123933"

  4. Kem T

    Feb 17 Pre-Release Testers, Xojo Pro New York

    Good catch. Can you send that change to the project?

  5. Really sorry but I've modified your code a lot to fit in with my app so the changes I've made are not in your project.

    I'm also not using source control and use subversion not git for my projects.

    You can just copy the shell code above manually when you get the chance. You'll be able to see easily where it slots into the existing code. :)

  6. I would also suggest adding the option to quit and relaunch as admin (see link below) if the updater encounters a write permission error which I have found if the app is located within Windows "Program Files" folder:

    http://developer.xojo.com/elevating-user-access-control

    When the write permission is denied I now give the user the option to relaunch as admin, go to web updates page or cancel.

    It works quite well, you just have to call the ExecuteWithUAC() method on App.CancelClose event and intercept the command line parameter on App.Open event to automatically re-check for updates again so the user can pick up where they left off before the write permission error occurred.

  7. Kem T

    Feb 17 Pre-Release Testers, Xojo Pro New York

    That can be done from without Kaju and I'd rather find a way to do this on all platforms if I'm going to do it at all.

  8. Sure, it's just the easiest way I've found to get around the Windows write permission issue that only ever happens for me when trying to auto-update the app within the Program Files folder.

    I'm yet to try Kaju on the Mac so will report back my findingss when I do.

    Thanks again for such a great utility!

  9. Kem T

    Feb 17 Pre-Release Testers, Xojo Pro New York

    I could probably do something similar via an AppleScript that calls an authorized shell on the Mac, but that would leave out Linux.

  10. Sure, that would be great. I only build for Windows and Mac so it would work for me but obviously it would be good for Linux developers to have a solution too. I really have no idea about Linux at all though so I'm afraid I can't offer any ideas on that front.

    One thing I did note about that example is that you need to add Chr(34) around f.NativePath since the script failed during testing on a test user account that by default did not have admin rights:

    sh.Execute("Wscript.exe " + Chr(34) + f.NativePath + Chr(34) )
  11. Kem T

    Feb 17 Pre-Release Testers, Xojo Pro New York

    To be clear, I won't be doing any of this until I need it, and I may never need it. If someone wants this functionality, they should write it and submit it back to the project.

    At least, that's how open-source is supposed to work...

  12. Sure. Good to discuss though in case others are using Kaju and run into similar problems.

  13. 2 days ago

    Beatrix W

    2 days ago Pre-Release Testers Europe (Germany)

    Don't do a version with the number 4.0.4.

    I wanted to check why I get "an error occurred" when loading an update after updating from 4.0.3 to 4.0.4. I changed the version information to an older version and did some debugging. When coming to the code

    				dim raw as string = http.Get( url, 10 )
    				if http.HTTPStatusCode = 404 or instr(raw, "404") > 0 then // Not found
    						mResult = ResultType.NoUpdateAvailable
    						exit do
    						
    				elseif raw = "" then
    						if HandleError( KajuLocale.kErrorNoUpdateData ) then
    								continue do
    						else
    								exit do
    						end if
    				end if

    it looked at first glance like the socket had problems with getting the update data. Instead I have a download url

    "URL":"http://www.mothsoftware.com/downloads/MailArchiverX404.dmg"

  14. Beatrix W

    2 days ago Pre-Release Testers Europe (Germany)

    The download complete event has the same problem:

    if instr(url, "404") > 0 then
  15. Kem T

    2 days ago Pre-Release Testers, Xojo Pro New York

    D'oh!

  16. Kem T

    2 days ago Pre-Release Testers, Xojo Pro New York

    Wait, that's not in the project code...

  17. Kem T

    2 days ago Pre-Release Testers, Xojo Pro New York

    This is the original code:

      dim raw as string = http.Get( url, 5 )
      if http.HTTPStatusCode = 404 then // Not found
        mResult = ResultType.NoUpdateAvailable
        exit do
        
      elseif raw = "" then
        if HandleError( KajuLocale.kErrorNoUpdateData ) then
          continue do
        else
          exit do
        end if
      end if
     
  18. Tim P

    2 days ago Pre-Release Testers, Xojo Pro Rochester, NY

    For anyone who didn't notice the difference like me, Beatrix's version is checking the response text for "404" as well.

  19. Kem T

    2 days ago Pre-Release Testers, Xojo Pro New York

    Right. I'm not sure why that's needed, but it you really want to do that, at least use a regular expression to make sure the 404 is standalone, and something else to make sure the JSON markers for the packet are not there.

  20. yesterday

    Beatrix W

    yesterday Pre-Release Testers Europe (Germany)

    Hmm.. as the senior moments are getting worse and worse: I seem to remember that the socket didn't give the proper status code. Therefore, I added the code to shoot myself into the foot.

  21. Tim P

    yesterday Pre-Release Testers, Xojo Pro Rochester, NY
    Edited yesterday by Tim P

    @Beatrix W Hmm.. as the senior moments are getting worse and worse: I seem to remember that the socket didn't give the proper status code. Therefore, I added the code to shoot myself into the foot.

    Perhaps you might want to search for "file not found" in the response text instead of "404"

    It's not exactly a good workaround for the socket not having the right response code, but it's less likely to result in a false positive match.

or Sign Up to reply!