mirror of
https://github.com/kovetskiy/mark.git
synced 2026-04-18 12:11:12 +00: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:
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user