Fix clean shutdown with portmaster-control

Also, only download portmaster-core on initial run of portmaster-control.

Fixes #7
This commit is contained in:
Daniel
2019-07-04 16:43:07 +02:00
parent b5cc3121ae
commit 2bc0da6700
6 changed files with 173 additions and 105 deletions

View File

@@ -11,6 +11,10 @@ import (
"github.com/safing/portmaster/updates"
)
var (
oldBinSuffix = "-old"
)
func checkForUpgrade() (update *updates.File) {
info := info.GetInfo()
file, err := updates.GetLocalPlatformFile("control/portmaster-control")
@@ -25,6 +29,8 @@ func checkForUpgrade() (update *updates.File) {
func doSelfUpgrade(file *updates.File) error {
// FIXME: fix permissions if needed
// get destination
dst, err := os.Executable()
if err != nil {
@@ -36,7 +42,7 @@ func doSelfUpgrade(file *updates.File) error {
}
// mv destination
err = os.Rename(dst, dst+"_old")
err = os.Rename(dst, dst+oldBinSuffix)
if err != nil {
return err
}
@@ -105,7 +111,7 @@ func removeOldBin() error {
}
// delete old
err = os.Remove(dst + "_old")
err = os.Remove(dst + oldBinSuffix)
if err != nil {
if !os.IsNotExist(err) {
return err