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