Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic app.ini and path checks to doctor cmd #10064

Merged
merged 13 commits into from
Jan 30, 2020
Prev Previous commit
Next Next commit
Make /custom dir not mandatory
  • Loading branch information
guillep2k committed Jan 29, 2020
commit 19f67bd227e0b4ea4ac0f9ae4a5b601dd2514327
24 changes: 14 additions & 10 deletions cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ func runDoctorPathInfo(ctx *cli.Context) ([]string, error) {

fail := false

check := func(name, path string, is_dir, is_write bool) {
check := func(name, path string, is_dir, required, is_write bool) {
res = append(res, fmt.Sprintf("%-25s '%s'", name+":", path))
if fi, err := os.Stat(path); err != nil {
res = append(res, fmt.Sprintf(" ERROR: %v", err))
fail = true
if required {
res = append(res, fmt.Sprintf(" ERROR: %v", err))
fail = true
} else {
res = append(res, fmt.Sprintf(" NOTICE: not accessible (%v)", err))
}
return
} else if is_dir && !fi.IsDir() {
res = append(res, " ERROR: not a directory")
Expand All @@ -132,16 +136,16 @@ func runDoctorPathInfo(ctx *cli.Context) ([]string, error) {
}

// Note print paths inside quotes to make any leading/trailing spaces evident
check("Configuration File Path", setting.CustomConf, false, false)
check("Repository Root Path", setting.RepoRootPath, true, true)
check("Data Root Path", setting.AppDataPath, true, true)
check("Custom File Root Path", setting.CustomPath, true, false)
check("Work directory", setting.AppWorkPath, true, false)
check("Log Root Path", setting.LogRootPath, true, true)
check("Configuration File Path", setting.CustomConf, false, true, false)
check("Repository Root Path", setting.RepoRootPath, true, true, true)
check("Data Root Path", setting.AppDataPath, true, true, true)
check("Custom File Root Path", setting.CustomPath, true, false, false)
check("Work directory", setting.AppWorkPath, true, true, false)
check("Log Root Path", setting.LogRootPath, true, true, true)

if options.IsDynamic() {
// Do not check/report on StaticRootPath if data is embedded in Gitea (-tags bindata)
check("Static File Root Path", setting.StaticRootPath, true, false)
check("Static File Root Path", setting.StaticRootPath, true, true, false)
}

if fail {
Expand Down