Skip to content

Commit 35cad24

Browse files
committed
Better checks and logging, test for failure case
1 parent e3825a7 commit 35cad24

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/setting/setting.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,21 @@ func getAppPath() (string, error) {
456456
if snap != "" && strings.HasPrefix(appPath, snap) {
457457
split := strings.Split(appPath, "/")
458458
if len(split) >= 3 {
459+
oldAppPath := appPath
459460
split[len(split)-2] = "current"
460-
appPath = strings.Join(split, "/")
461+
newAppPath := strings.Join(split, "-")
462+
appPath, err = exec.LookPath(newAppPath)
463+
if err != nil {
464+
appPath = oldAppPath
465+
log.error("Could not change AppPath from %s to %s while running in snap. Hooks for new repositories may fail after snap upgrades.", oldAppPath, newAppPath)
466+
} else {
467+
appPath = newAppPath
468+
log.debug("Apppath changed from %s to %s because we are running in snap.", oldAppPath, newAppPath)
469+
}
461470
}
462471
}
463472

464-
return appPath, err
473+
return appPath, nil
465474
}
466475

467476
func getWorkPath(appPath string) string {

0 commit comments

Comments
 (0)