mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-16 18:38:52 -07:00
* auto-update: check if executable file exists
This commit is contained in:
parent
94d86eee10
commit
1792fd3e0f
@ -148,6 +148,15 @@ type updateInfo struct {
|
||||
newBinName string // Full path to the new executable file
|
||||
}
|
||||
|
||||
// Return TRUE if file exists
|
||||
func fileExists(fn string) bool {
|
||||
_, err := os.Stat(fn)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Fill in updateInfo object
|
||||
func getUpdateInfo(jsonData []byte) (*updateInfo, error) {
|
||||
var u updateInfo
|
||||
@ -190,6 +199,9 @@ func getUpdateInfo(jsonData []byte) (*updateInfo, error) {
|
||||
binName = "AdGuardHome.exe"
|
||||
}
|
||||
u.curBinName = filepath.Join(workDir, binName)
|
||||
if !fileExists(u.curBinName) {
|
||||
return nil, fmt.Errorf("Executable file %s doesn't exist", u.curBinName)
|
||||
}
|
||||
u.bkpBinName = filepath.Join(u.backupDir, binName)
|
||||
u.newBinName = filepath.Join(u.updateDir, "AdGuardHome", binName)
|
||||
if strings.HasSuffix(pkgFileName, ".zip") {
|
||||
|
Loading…
Reference in New Issue
Block a user