1
0
mirror of https://github.com/taigrr/go-selfupdate synced 2025-01-18 04:33:12 -08:00

last version adapted

This commit is contained in:
System Administrator 2014-11-22 08:21:52 +02:00
parent a88bde6abc
commit c2f128aaaf

View File

@ -16,9 +16,9 @@ import (
"math/rand" "math/rand"
"net/http" "net/http"
"os" "os"
"path/filepath"
"runtime" "runtime"
"time" "time"
"path/filepath"
) )
const ( const (
@ -29,6 +29,7 @@ const (
const devValidTime = 7 * 24 * time.Hour const devValidTime = 7 * 24 * time.Hour
var ErrHashMismatch = errors.New("new file hash mismatch after patch") var ErrHashMismatch = errors.New("new file hash mismatch after patch")
var up = update.New()
// Update protocol. // Update protocol.
// //
@ -76,7 +77,7 @@ func (u *Updater) getExecRelativeDir(dir string) string {
func (u *Updater) BackgroundRun() { func (u *Updater) BackgroundRun() {
os.MkdirAll(u.getExecRelativeDir(u.Dir), 0777) os.MkdirAll(u.getExecRelativeDir(u.Dir), 0777)
if u.wantUpdate() { if u.wantUpdate() {
if err := update.SanityCheck(); err != nil { if err := up.CanUpdate(); err != nil {
// fail // fail
return return
} }
@ -141,7 +142,7 @@ func (u *Updater) update() error {
// it can't be renamed if a handle to the file is still open // it can't be renamed if a handle to the file is still open
old.Close() old.Close()
err, errRecover := update.FromStream(bytes.NewBuffer(bin)) err, errRecover := up.FromStream(bytes.NewBuffer(bin))
if errRecover != nil { if errRecover != nil {
return fmt.Errorf("update and recovery errors: %q %q", err, errRecover) return fmt.Errorf("update and recovery errors: %q %q", err, errRecover)
} }