Fix: missed errors, minor formatting issues

This commit is contained in:
Yoann La Cancellera
2023-11-22 11:00:34 +01:00
committed by Sveta Smirnova
parent 2a97f061db
commit bb6c5e1abd
5 changed files with 15 additions and 9 deletions

View File

@@ -132,10 +132,13 @@ func execGrepAndIterate(path, compiledRegex string, stdout chan<- string) error
cmd := exec.Command(CLI.GrepCmd, "-P", compiledRegex, path)
out, _ := cmd.StdoutPipe()
out, err := cmd.StdoutPipe()
if err != nil {
return errors.Wrap(err, "could not open stdout pipe")
}
defer out.Close()
err := cmd.Start()
err = cmd.Start()
if err != nil {
return errors.Wrapf(err, "failed to search in %s", path)
}

View File

@@ -50,7 +50,11 @@ func (l *list) Run() error {
}
if CLI.Verbosity == types.Debug {
fmt.Println(translate.DBToJson())
out, err := translate.DBToJson()
if err != nil {
return errors.Wrap(err, "could not dump translation structs to json")
}
fmt.Println(out)
}
display.TimelineCLI(timeline, CLI.Verbosity)

View File

@@ -25,7 +25,7 @@ type translationsDB struct {
// incase methods changed in the middle, tls=>ssl
IPToMethods map[string][]translationUnit
rwlock *sync.RWMutex
rwlock sync.RWMutex
}
var AssumeIPStable bool = true
@@ -42,7 +42,6 @@ func initTranslationsDB() {
HashToNodeNames: map[string][]translationUnit{},
IPToMethods: map[string][]translationUnit{},
IPToNodeNames: map[string][]translationUnit{},
rwlock: &sync.RWMutex{},
}
}
@@ -51,9 +50,9 @@ func ResetDB() {
initTranslationsDB()
}
func DBToJson() string {
out, _ := json.MarshalIndent(db, "", "\t")
return string(out)
func DBToJson() (string, error) {
out, err := json.MarshalIndent(db, "", "\t")
return string(out), err
}
func GetDB() translationsDB {

View File

@@ -45,6 +45,7 @@ func (cs Conflicts) OldestUnresolved() *Conflict {
}
return nil
}
func (cs Conflicts) ConflictFromMD5(md5 string) *Conflict {
for _, c := range cs {
for _, vote := range c.VotePerNode {

View File

@@ -75,7 +75,6 @@ func (ctx *LogCtx) SetState(s string) {
if !utils.SliceContains([]string{"SYNCED", "JOINED", "DONOR", "DESYNCED", "JOINER", "PRIMARY", "NON-PRIMARY", "OPEN", "CLOSED", "DESTROYED", "ERROR", "RECOVERY"}, s) {
return
}
//ctx.state[ctx.FileType] = append(ctx.state[ctx.FileType], s)
switch ctx.FileType {
case "post.processing.log":
ctx.statePostProcessingLog = s