diff options
| author | 2025-11-17 00:00:00 +0000 | |
|---|---|---|
| committer | 2025-11-17 00:00:00 +0000 | |
| commit | 1de28c5fc4331ed3841661246be167c450ff7986 (patch) | |
| tree | ebe791cf909b8fb09d144457a83d50fbe5047ff8 /pack_pack.go | |
| parent | Remove an unnecessary blank line (diff) | |
| signature | ||
Revert "Compute checksum when reading packfiles"
This reverts commit 1dcb92427c23d0a8b23c0154b892243c749afa5a.
Yeah this should be part of the network protocol rather than being done
on *every read*.
Diffstat (limited to 'pack_pack.go')
| -rw-r--r-- | pack_pack.go | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/pack_pack.go b/pack_pack.go index 6d740b73..5c2c8628 100644 --- a/pack_pack.go +++ b/pack_pack.go @@ -487,7 +487,7 @@ type packFile struct { closeMu sync.Once } -func openPackFile(absPath, rel string, hashSize int) (*packFile, error) { +func openPackFile(absPath, rel string) (*packFile, error) { f, err := os.Open(absPath) if err != nil { return nil, err @@ -498,7 +498,7 @@ func openPackFile(absPath, rel string, hashSize int) (*packFile, error) { _ = f.Close() return nil, err } - if stat.Size() < 12+int64(hashSize) { + if stat.Size() < 12 { _ = f.Close() return nil, ErrInvalidObject } @@ -532,26 +532,6 @@ func openPackFile(absPath, rel string, hashSize int) (*packFile, error) { _ = syscall.Munmap(region) return nil, err } - - if len(region) < hashSize { - _ = syscall.Munmap(region) - return nil, ErrInvalidObject - } - dataEnd := len(region) - hashSize - checksumInFile := region[dataEnd:] - - hashFn, ok := hashFuncs[hashSize] - if !ok { - _ = syscall.Munmap(region) - return nil, fmt.Errorf("furgit: unsupported hash size %d", hashSize) - } - - computedHash := hashFn(region[:dataEnd]) - if !bytes.Equal(computedHash.data[:hashSize], checksumInFile) { - _ = syscall.Munmap(region) - return nil, fmt.Errorf("furgit: pack checksum mismatch in %s", rel) - } - return &packFile{ relPath: rel, size: stat.Size(), |
