mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-01 21:02:33 +00:00
fix: Include scale into the hash
Should fix https://github.com/kovetskiy/mark/issues/683
This commit is contained in:
11
d2/d2.go
11
d2/d2.go
@@ -4,7 +4,9 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -63,7 +65,14 @@ func ProcessD2(title string, d2Diagram []byte, scale float64) (attachment.Attach
|
||||
return attachment.Attachment{}, err
|
||||
}
|
||||
|
||||
checkSum, err := attachment.GetChecksum(bytes.NewReader(d2Diagram))
|
||||
scaleAsBytes := make([]byte, 8)
|
||||
|
||||
binary.LittleEndian.PutUint64(scaleAsBytes, math.Float64bits(scale))
|
||||
|
||||
d2Bytes := append(d2Diagram, scaleAsBytes...)
|
||||
|
||||
checkSum, err := attachment.GetChecksum(bytes.NewReader(d2Bytes))
|
||||
|
||||
log.Debugf(nil, "Checksum: %q -> %s", title, checkSum)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -75,7 +75,7 @@ func TestExtractD2Image(t *testing.T) {
|
||||
Filename: "example.png",
|
||||
Name: "example",
|
||||
Replace: "example",
|
||||
Checksum: "58fa387384181445e2d8f90a8c7fda945cb75174f73e8b9853ff59b9e0103ddd",
|
||||
Checksum: "40e75f93e09da9242d4b1ab8e2892665ec7d5bd1ac78a4b65210ee219cf62297",
|
||||
ID: "",
|
||||
Width: "198",
|
||||
Height: "441",
|
||||
|
||||
Reference in New Issue
Block a user