Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update loop #31

Open
swisscheez2 opened this issue Mar 27, 2023 · 11 comments
Open

Update loop #31

swisscheez2 opened this issue Mar 27, 2023 · 11 comments

Comments

@swisscheez2
Copy link

I am trying to get this to run for my wails-vite-svelte-tailwindcss app.

I didn't test non-managed yet. But for Managed I can see that I get stuck in an update loop most of the time.

it recognizes that there is an update and proceeds to download it renames itself twice to .old and then tries to re-download it. quite weird what's happening. also if there is already an .old version of the app in the same folder it will fail to update. In my opinion it would be better to allow us to handle it how we like. for example deleting any file before we trying to rename the app.

I see the thing is stuck in an update loop despite downloading the updated version from server from the logfile entries I see.

@andydotxyz
Copy link

The sounds like an issue we heard about regarding daylight saving. If so it would be fixed by applying #29.

@swisscheez2
Copy link
Author

swisscheez2 commented Mar 27, 2023

I just tried that, but it didn't seem to improve my issues yet. I must be doing something wrong.

The app is running on windows exclusively I will do some more testing myself and report back my findings.

I also tried without setting any time to Current before passing that to config and then to selfupdate.manage(), I tried just with build numbers just in case that would work. But it also loops at the moment. I must be misunderstanding something is my best guess.

@swisscheez2
Copy link
Author

swisscheez2 commented Mar 27, 2023

if I remove the Version field I can at least get rid of my update loop issue. There is one remaining problem since on Windows, the removal of /path/to/target.old always fails it tries to hide the file from what I see in Doc. But I think it fails ( the logs don't show anything), I see that it renames the "updated" executable to .old and the "old" executable as well. and both have a . in front of them.

@Bluebugs
Copy link

The '.' is a trick to make the file invisible. On Windows, when a binary is in use, it can not be removed which means we can only move it and hide it. But when the next update happen, the old file can be removed as it is not in use anymore. With that in mind, I think what you describe is happening with the .old file is ok.

Now, the main question is why is it looping. Did you set LogError to get error message of what is going on? If you are getting the old file, it seems that the update of the binary actually did happen, but the restart is somehow failing (Did you set an ExitCallback?). That would be my guess, but logs will tell.

@andydotxyz
Copy link

The '.' is a trick to make the file invisible.

I don't think that works by default on Windows

@swisscheez2
Copy link
Author

swisscheez2 commented Mar 27, 2023

I did add the loggers and it logs everything that happens even the debug messages.

I solved it like this:

the update loop always happens when If I try and use Current in options. so I removed that.

the second issue I solved like this

when it did an update I would find myself with two files with the same name .myapp.exe.old in the same directory.

I noticed that somehow the move from the new executable to the new program causes the issue with there being two .old files so atm I use a hotfix by sleeping for a second there. (in apply.go)


err = os.Rename(opts.TargetPath, oldPath)
	if err != nil {
	
		return err
	}
	
	// wait for the old executable to be successfully renamed temp fix
	time.Sleep(1 * time.Second)

	// move the new executable in to become the new program
	err = os.Rename(newPath, opts.TargetPath)
	

The last thing I did since I did not like the fact that the file only gets "hidden" (as you said this doesn't work on windows) is I just clean up any .old files on the start of my app (walk through all files check extension and delete if its a .old file).

this way when update is done and it gets relaunched the .old file gets deleted 

@Bluebugs
Copy link

It is weird that the existing old executable doesn't get deleted or that it takes time for that to happen. The only things that would prevent it is if that binary is still on use. Is it possible that your application shutdown is actually slower than the entire update process and the previous executable is still running? Just trying to understand what it's going on, I don't like having sleep to solve problems!

@swisscheez2
Copy link
Author

swisscheez2 commented Mar 28, 2023

the issue is it doesn't get renamed properly, without a sleep we end up with two executables with the same names and both a . Old ending. Without investigating too much what I think is happening is the first rename. Happens after the second one so we end up with two identically named files .

If I have time I will investigate it further and post the details here

since it works after a sleep and since the instance where you rename the files is in the first instance of your app the app is still running at that point so it should not work by just adding a sleep. So I don't think the binary is still "in use"

@andydotxyz
Copy link

Thanks for digging into this, it certainly is a strange issue!
Is there anything notable about your filesystem or storage hardware?

@swisscheez2
Copy link
Author

swisscheez2 commented Mar 28, 2023

Thanks for digging into this, it certainly is a strange issue! Is there anything notable about your filesystem or storage hardware?

nothing special comes to my mind. the file is on my c drive on a Samsung SSD 860 EVO 1TB . Running
Windows 10 Professionnel
Version 22H2
Build 19045.2130

I will try to remove the sleep and see if I get a different behaviour depending on the drive

oh right the filesystem is ntfs

@Jacalz
Copy link

Jacalz commented Oct 27, 2023

This seems to be the very same as Jacalz/rymdport#116 that was opened a while back. You download the latest release from https://github.com/Jacalz/rymdport/releases/latest and it immediately asks for a new update even though it is the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants