Updating is working!!
This commit is contained in:
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/nelsam/gxui"
|
||||
"github.com/nelsam/gxui/drivers/gl"
|
||||
@@ -10,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version = "0.1.1.1"
|
||||
version = "1.1.0.0"
|
||||
defIni = "[basic]\ntheme=dk"
|
||||
)
|
||||
|
||||
@@ -27,6 +29,8 @@ var (
|
||||
)
|
||||
|
||||
func main() {
|
||||
updated := false
|
||||
os.MkdirAll("PortableApps/LinuxPACom", 0777)
|
||||
stat := versionDL()
|
||||
if stat {
|
||||
res := getVersionFileInfo()
|
||||
@@ -34,6 +38,7 @@ func main() {
|
||||
stat = checkForUpdate(res)
|
||||
if stat {
|
||||
downloadUpdate(res)
|
||||
updated = true
|
||||
} else {
|
||||
fmt.Println("Failed DL")
|
||||
}
|
||||
@@ -43,10 +48,18 @@ func main() {
|
||||
} else {
|
||||
fmt.Println("Failed Version DL")
|
||||
}
|
||||
if updated {
|
||||
cmd := exec.Command("./LinuxPA")
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Start()
|
||||
fmt.Println("updated!")
|
||||
} else {
|
||||
master = make(map[string][]app)
|
||||
linmaster = make(map[string][]app)
|
||||
gl.StartDriver(appMain)
|
||||
}
|
||||
}
|
||||
|
||||
func appMain(dri gxui.Driver) {
|
||||
dr = dri
|
||||
|
||||
@@ -20,14 +20,11 @@ const (
|
||||
|
||||
//Returns if success
|
||||
func versionDL() bool {
|
||||
versionFile, err := os.Open("PortableApps/LinuxPACom/Version")
|
||||
if err != nil {
|
||||
versionFile, err = os.Create("PortableApps/LinuxPACom/Version")
|
||||
versionFile, err := os.Create("PortableApps/LinuxPACom/Version")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
defer versionFile.Close()
|
||||
versionFile.Chmod(0777)
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
@@ -35,7 +32,6 @@ func versionDL() bool {
|
||||
},
|
||||
}
|
||||
response, err := check.Get(versionURL)
|
||||
defer response.Body.Close()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -85,6 +81,7 @@ func downloadUpdate(newVersion string) bool {
|
||||
return false
|
||||
}
|
||||
fil, err := os.Create("LinuxPA")
|
||||
fil.Chmod(0777)
|
||||
defer fil.Close()
|
||||
if err != nil {
|
||||
os.Rename(".LinuxPA.old", "LinuxPA")
|
||||
|
||||
Reference in New Issue
Block a user