Added safety

This commit is contained in:
root
2023-02-13 12:01:58 +01:00
parent 00cceeaeac
commit 3da2abb2fa

View File

@@ -117,6 +117,9 @@ func getVersions() []string {
res, err := http.Get(url) res, err := http.Get(url)
checkError(err) checkError(err)
if err != nil{
return nil
}
defer res.Body.Close() defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body) body, err := ioutil.ReadAll(res.Body)
@@ -185,7 +188,10 @@ func getCurrentVersion() string {
func loadCurrent() { func loadCurrent() {
versions := getVersions() versions := getVersions()
if getCurrentVersion() != versions[0] { if versions == nil{
return
}
if getCurrentVersion() != versions[0]{
file := loadDdragon(versions[0]) file := loadDdragon(versions[0])
ioutil.WriteFile("current.txt", []byte(versions[0]), 0777) ioutil.WriteFile("current.txt", []byte(versions[0]), 0777)