Skip to content

Commit 46ed1d7

Browse files
fix: download-all returns error on partial failures (#50)
* fix: return error from --download-all when downloads fail downloadAllAttachments was returning nil even when individual file downloads failed, causing the CLI to exit 0. Callers (and scripts) had no way to detect partial failures. * fix: also return error in JSON output path The --json code path returned early before the error check, so download failures with --json still exited 0. Co-authored-by: gemini-code-assist[bot] <gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <gemini-code-assist[bot]@users.noreply.github.com>
1 parent 12f3bab commit 46ed1d7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/cmd/confluence/page/attachment.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,13 @@ func downloadAllAttachments(opts *AttachmentOptions, confluence *api.ConfluenceS
313313
Downloads: downloads,
314314
Errors: errors,
315315
}
316-
return output.JSON(opts.IO.Out, result)
316+
if err := output.JSON(opts.IO.Out, result); err != nil {
317+
return err
318+
}
319+
if len(errors) > 0 {
320+
return fmt.Errorf("failed to download %d attachment(s)", len(errors))
321+
}
322+
return nil
317323
}
318324

319325
if len(errors) > 0 {
@@ -324,6 +330,9 @@ func downloadAllAttachments(opts *AttachmentOptions, confluence *api.ConfluenceS
324330
}
325331

326332
fmt.Fprintf(opts.IO.Out, "\nDownloaded %d of %d attachments to %s\n", len(downloads), len(attachments), opts.OutputDir)
333+
if len(errors) > 0 {
334+
return fmt.Errorf("failed to download %d attachment(s)", len(errors))
335+
}
327336
return nil
328337
}
329338

0 commit comments

Comments
 (0)