Store each hash as its raw 32 bytes in a BLOB column (closes #134)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The head, tail and content columns of the files table are BLOB NOT NULL and hold the raw 32-byte SHA-256, half the size of the hex text, in the table and in the files_signature index. The hash phase, the records, report and trees carry each hash as a [sha256.Size]byte and compare it with ==; nothing is hex-encoded. Reading a record whose hash column is not 32 bytes is an error naming its path. In the tests, testHash is a stand-in hash: a string's bytes padded with zeros, so fixtures keep the sort order their strings give. Judgement call: a hash of the wrong length is refused on reading, not copied silently. Model: opus-5-5
This commit was merged in pull request #138.
This commit is contained in:
+7
-4
@@ -23,11 +23,14 @@ const infoCountLine = "[2/2] count: counting the records, elapsed 0s, " +
|
||||
// infoRecs are four records: a duplicate pair, a file of 20 MiB and
|
||||
// another small file.
|
||||
func infoRecs() []scanRec {
|
||||
h, tl, c, u := testHash("h"), testHash("t"), testHash("c"), testHash("u")
|
||||
bigH, bigT, bigC := testHash("bh"), testHash("bt"), testHash("bc")
|
||||
|
||||
return []scanRec{
|
||||
{size: 5, head: "h", tail: "t", content: "c", path: "/d/a"},
|
||||
{size: 5, head: "h", tail: "t", content: "c", path: "/d/b"},
|
||||
{size: 20 << 20, head: "bh", tail: "bt", content: "bc", path: "/d/big"},
|
||||
{size: 7, head: "u", tail: "u", content: "u", path: "/d/unique"},
|
||||
{size: 5, head: h, tail: tl, content: c, path: "/d/a"},
|
||||
{size: 5, head: h, tail: tl, content: c, path: "/d/b"},
|
||||
{size: 20 << 20, head: bigH, tail: bigT, content: bigC, path: "/d/big"},
|
||||
{size: 7, head: u, tail: u, content: u, path: "/d/unique"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user