Skip to content

Commit

Permalink
make verify robust for padded archives [#200]
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Jan 6, 2025
1 parent 967ba9d commit 1860585
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pmtiles/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ func Verify(_ *log.Logger, file string) error {
fileInfo, _ := os.Stat(file)

lengthFromHeader := int64(HeaderV3LenBytes + header.RootLength + header.MetadataLength + header.LeafDirectoryLength + header.TileDataLength)
lengthFromHeaderWithPadding := int64(16384 + header.MetadataLength + header.LeafDirectoryLength + header.TileDataLength)

if fileInfo.Size() != lengthFromHeader {
return fmt.Errorf("Total length of archive %v does not match header %v", fileInfo.Size(), lengthFromHeader)
if fileInfo.Size() != lengthFromHeader && fileInfo.Size() != lengthFromHeaderWithPadding {
return fmt.Errorf("Total length of archive %v does not match header %v or %v (padded)", fileInfo.Size(), lengthFromHeader, lengthFromHeaderWithPadding)
}

var CollectEntries func(uint64, uint64, func(EntryV3))
Expand Down

0 comments on commit 1860585

Please sign in to comment.