Fix wrapped snapshot json output
If there are a lot of snapshots, the JSON output can sometimes be wrapped to multiple console lines and need to be joined.
This commit is contained in:
parent
84095f9875
commit
9cdf37c680
@ -354,9 +354,11 @@ func (rcmd Restic) ReadSnapshots() ([]Snapshot, error) {
|
|||||||
return nil, fmt.Errorf("no snapshot output to parse: %w", ErrRestic)
|
return nil, fmt.Errorf("no snapshot output to parse: %w", ErrRestic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
singleLineOutput := strings.Join(output.Stdout.Lines, "")
|
||||||
|
|
||||||
snapshots := new([]Snapshot)
|
snapshots := new([]Snapshot)
|
||||||
if err = json.Unmarshal([]byte(output.Stdout.Lines[0]), snapshots); err != nil {
|
if err = json.Unmarshal([]byte(singleLineOutput), snapshots); err != nil {
|
||||||
return nil, fmt.Errorf("failed parsing snapshot results from %s: %w", output.Stdout.Lines[0], err)
|
return nil, fmt.Errorf("failed parsing snapshot results from %s: %w", singleLineOutput, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return *snapshots, nil
|
return *snapshots, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user