Pull request: 4219-updater-1

Merge in DNS/adguard-home from 4219-updater-1 to master

Squashed commit of the following:

commit 5721a0032150c9a0b8bd940542860c262adfe646
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Aug 31 14:50:56 2022 +0300

    updater: imp code

commit a18ccb2174af3d68c85e40aed5167c01523b0e67
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Aug 31 13:49:23 2022 +0300

    updater: exe name

commit deb5c7bee63a3b5eb7aa722268857ebcfc7f053d
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Aug 31 10:05:00 2022 +0300

    updater: exe name
This commit is contained in:
Dimitry Kolyshev
2022-08-31 14:54:46 +03:00
parent 5cc2a2cd0c
commit c098960b39
2 changed files with 34 additions and 31 deletions

View File

@@ -117,7 +117,7 @@ func (u *Updater) Update() (err error) {
return err
}
err = u.prepare(filepath.Base(execPath))
err = u.prepare(execPath)
if err != nil {
return err
}
@@ -169,7 +169,7 @@ func (u *Updater) VersionCheckURL() (vcu string) {
}
// prepare fills all necessary fields in Updater object.
func (u *Updater) prepare(exeName string) (err error) {
func (u *Updater) prepare(exePath string) (err error) {
u.updateDir = filepath.Join(u.workDir, fmt.Sprintf("agh-update-%s", u.newVersion))
_, pkgNameOnly := filepath.Split(u.packageURL)
@@ -185,7 +185,7 @@ func (u *Updater) prepare(exeName string) (err error) {
updateExeName = "AdGuardHome.exe"
}
u.backupExeName = filepath.Join(u.backupDir, exeName)
u.backupExeName = filepath.Join(u.backupDir, filepath.Base(exePath))
u.updateExeName = filepath.Join(u.updateDir, updateExeName)
log.Debug(
@@ -195,7 +195,7 @@ func (u *Updater) prepare(exeName string) (err error) {
u.packageURL,
)
u.currentExeName = filepath.Join(u.workDir, exeName)
u.currentExeName = exePath
_, err = os.Stat(u.currentExeName)
if err != nil {
return fmt.Errorf("checking %q: %w", u.currentExeName, err)