gopass/internal/action/update.go
Dominik Schulz 7962f08c92
Allow updating gopass.exe on Windows (#2345)
Windows will lock files being executed but we should be able to rename
them.

Fixes #2011

RELEASE_NOTES=[BUGFIX] Fix updater on Windows.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2022-09-20 21:56:42 +02:00

32 lines
768 B
Go

package action
import (
"github.com/gopasspw/gopass/internal/action/exit"
"github.com/gopasspw/gopass/internal/out"
"github.com/gopasspw/gopass/internal/updater"
"github.com/gopasspw/gopass/pkg/ctxutil"
"github.com/urfave/cli/v2"
)
// Update will start the interactive update assistant.
func (s *Action) Update(c *cli.Context) error {
_ = s.rem.Reset("update")
ctx := ctxutil.WithGlobalFlags(c)
if s.version.String() == "0.0.0+HEAD" {
out.Errorf(ctx, "Can not check version against HEAD")
return nil
}
out.Printf(ctx, "⚒ Checking for available updates ...")
if err := updater.Update(ctx, s.version); err != nil {
return exit.Error(exit.Unknown, err, "Failed to update gopass: %s", err)
}
out.OKf(ctx, "gopass is up to date")
return nil
}