Skip to content

Commit

Permalink
fix: relax output parsing to skip over warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Dec 8, 2023
1 parent a8762dc commit 8f85b74
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/restic/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (b *BackupProgressEntry) Validate() error {
return nil
}

// readBackupProgressEntrys returns the summary event or an error if the command failed.
// readBackupProgressEntries returns the summary event or an error if the command failed.
func readBackupProgressEntries(cmd *exec.Cmd, output io.Reader, callback func(event *BackupProgressEntry)) (*BackupProgressEntry, error) {
scanner := bufio.NewScanner(output)
scanner.Split(bufio.ScanLines)
Expand Down Expand Up @@ -122,10 +122,12 @@ func readBackupProgressEntries(cmd *exec.Cmd, output io.Reader, callback func(ev
for scanner.Scan() {
var event BackupProgressEntry
if err := json.Unmarshal(scanner.Bytes(), &event); err != nil {
return nil, fmt.Errorf("failed to parse JSON: %w", err)
// skip it. This is a best-effort attempt to parse the output.
continue
}
if err := event.Validate(); err != nil {
return nil, err
// skip it. This is a best-effort attempt to parse the output.
continue
}

if callback != nil {
Expand Down

0 comments on commit 8f85b74

Please sign in to comment.