From 066f4aecd3ece8781db5b1d6d7d83db24e5ad2cb Mon Sep 17 00:00:00 2001 From: Gareth Date: Fri, 8 Dec 2023 00:29:35 -0800 Subject: [PATCH] fix: relax output parsing to skip over warnings --- pkg/restic/outputs.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/restic/outputs.go b/pkg/restic/outputs.go index 625b964a..a09a78d9 100644 --- a/pkg/restic/outputs.go +++ b/pkg/restic/outputs.go @@ -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) @@ -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 {