check ledger api default return empty list

This commit is contained in:
BaoXuebin 2022-10-15 19:24:49 +08:00
parent ab6188da2b
commit 0d172a3988
1 changed files with 3 additions and 5 deletions

View File

@ -213,20 +213,18 @@ func CheckLedger(c *gin.Context) {
ledgerConfig := script.GetLedgerConfigFromContext(c) ledgerConfig := script.GetLedgerConfigFromContext(c)
cmd := exec.Command("bean-check", script.GetLedgerIndexFilePath(ledgerConfig.DataPath)) cmd := exec.Command("bean-check", script.GetLedgerIndexFilePath(ledgerConfig.DataPath))
cmd.Stderr = &stderr cmd.Stderr = &stderr
output, err := cmd.Output() _, err := cmd.Output()
result := make([]string, 0)
if err != nil { if err != nil {
errors := strings.Split(stderr.String(), "\r\n") errors := strings.Split(stderr.String(), "\r\n")
result := make([]string, 0)
for _, e := range errors { for _, e := range errors {
if e == "" { if e == "" {
continue continue
} }
result = append(result, e) result = append(result, e)
} }
OK(c, result)
} else {
OK(c, string(output))
} }
OK(c, result)
} }
func createNewLedger(loginForm LoginForm, ledgerId string) (*script.Config, error) { func createNewLedger(loginForm LoginForm, ledgerId string) (*script.Config, error) {