mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-03 05:42:35 +00:00
UPD attachment.go: optimize checksum computation skipping when already set
This commit is contained in:
@@ -49,6 +49,13 @@ func ResolveAttachments(
|
|||||||
attachments []Attachment,
|
attachments []Attachment,
|
||||||
) ([]Attachment, error) {
|
) ([]Attachment, error) {
|
||||||
for i := range attachments {
|
for i := range attachments {
|
||||||
|
// Skip checksum computation if already set (e.g. by mermaid/d2 renderers
|
||||||
|
// which use the source content as the stable checksum rather than the
|
||||||
|
// rendered PNG bytes, which may be non-deterministic across environments).
|
||||||
|
if attachments[i].Checksum != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
checksum, err := GetChecksum(bytes.NewReader(attachments[i].FileBytes))
|
checksum, err := GetChecksum(bytes.NewReader(attachments[i].FileBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to get checksum for attachment %q: %w", attachments[i].Name, err)
|
return nil, fmt.Errorf("unable to get checksum for attachment %q: %w", attachments[i].Name, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user