mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-17 07:57:37 +08:00
fix: return error instead of panic in ResolveAttachments; fix wrong slice index in log
Two issues in attachment handling: 1. GetAttachments failure called panic(err) instead of returning an error, crashing the process on any API failure. 2. The 'keeping unmodified' log loop indexed into the original attachments slice using the range of existing, causing wrong names to be logged and a potential out-of-bounds panic when existing is longer than attachments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9e7f2cf9d5
commit
32577c91f4
@ -61,7 +61,7 @@ func ResolveAttachments(
|
||||
|
||||
remotes, err := api.GetAttachments(page.ID)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, karma.Format(err, "unable to get attachments for page %s", page.ID)
|
||||
}
|
||||
|
||||
existing := []Attachment{}
|
||||
@ -153,7 +153,7 @@ func ResolveAttachments(
|
||||
}
|
||||
|
||||
for i := range existing {
|
||||
log.Infof(nil, "keeping unmodified attachment: %q", attachments[i].Name)
|
||||
log.Infof(nil, "keeping unmodified attachment: %q", existing[i].Name)
|
||||
}
|
||||
|
||||
attachments = []Attachment{}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user