sanbornm/go-selfupdate

Update duration is more than 24h?

zyuyou opened this issue · 8 comments

func (u *Updater) wantUpdate() bool {
    path := u.getExecRelativeDir(u.Dir + upcktimePath)
    if u.CurrentVersion == "dev" || readTime(path).After(time.Now()) {
        return false
    }
    wait := 24*time.Hour + randDuration(24*time.Hour)
    return writeTime(path, time.Now().Add(wait))
}

Why can I update just once in 24 hours and more?

There isn't a reason, just a sane default. Maybe this should be a field on the Updater struct?

I wanted it to be updated when I restarted the app, why should I set an duration to stop my way?
So I think that it should always checking for updates when the app restarting.

That check is to limit how many times it looks for an update regardless of when an app is restarted. If your app was running for 4 days it would check 4 times by default. Even if you never restart your app.

Yes, I see. But I mean, it should check for updates at that moment when the app is starting. For now,the update duration may make it stop.

Some steps:

  1. version-1 would write next wanted check for update time to cktime file.
  2. version-2 is out, I would like to restart app to update version-1 to version-2.

But it won't work, because readTime(path).After(time.Now() is true. Unless I move cktime file away.

I agree you should be able to set a periodic check time as well as check on app start. I am open to pull requests if you want to make the change.

Yes, I want this feature. Thank you.

do you have any idea if people actually use this repo in 2020? ForceCheck doesn't appear to actually force checks and I ran into the same thing zyuyou did. I'd be willing to open a PR but can't get this to work in general so trying to decide if the community could use the PRs/effort or if I should just write something myself for my specific purpose

@stevenaldinger I still use it. I don't use ForceCheck or have a need to check on every app startup. I don't think a PR was ever submitted for either of these issues.

Also, I need to use this again for another project very soon. I'll review, test, and approve any PRs/efforts if you want to contribute. It looks like I also need to update this project to use Go modules and do some general cleanup.