1 Commits

Author SHA1 Message Date
Belac Darkstorm 9da352a315 Updating is working!! 2017-04-03 10:43:22 -05:00
2 changed files with 21 additions and 11 deletions
+17 -4
View File
@@ -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,9 +48,17 @@ func main() {
} else {
fmt.Println("Failed Version DL")
}
master = make(map[string][]app)
linmaster = make(map[string][]app)
gl.StartDriver(appMain)
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) {
+4 -7
View File
@@ -20,14 +20,11 @@ const (
//Returns if success
func versionDL() bool {
versionFile, err := os.Open("PortableApps/LinuxPACom/Version")
versionFile, err := os.Create("PortableApps/LinuxPACom/Version")
if err != nil {
versionFile, err = os.Create("PortableApps/LinuxPACom/Version")
if err != nil {
return false
}
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")