From 5936e6a4aab541a437fa9464468b51f91d019a2a Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 16 Jan 2026 02:09:12 +0900 Subject: internal/pkg: parallelise scrub This significantly improves scrubbing performance. Since the cache directory structure is friendly to simultaneous access, this is possible without synchronisation. Signed-off-by: Ophestra --- internal/pkg/dir.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'internal/pkg/dir.go') diff --git a/internal/pkg/dir.go b/internal/pkg/dir.go index e446c569..d0c3668d 100644 --- a/internal/pkg/dir.go +++ b/internal/pkg/dir.go @@ -196,15 +196,16 @@ func Flatten(fsys fs.FS, root string, w io.Writer) (n int, err error) { } // HashFS returns a checksum produced by hashing the result of [Flatten]. -func HashFS(fsys fs.FS, root string) (Checksum, error) { +func HashFS(buf *Checksum, fsys fs.FS, root string) error { h := sha512.New384() if _, err := Flatten(fsys, root, h); err != nil { - return Checksum{}, err + return err } - return (Checksum)(h.Sum(nil)), nil + h.Sum(buf[:0]) + return nil } // HashDir returns a checksum produced by hashing the result of [Flatten]. -func HashDir(pathname *check.Absolute) (Checksum, error) { - return HashFS(os.DirFS(pathname.String()), ".") +func HashDir(buf *Checksum, pathname *check.Absolute) error { + return HashFS(buf, os.DirFS(pathname.String()), ".") } -- cgit v1.3.1