From 1860585606464ca26b4dbded78df2ce640888dab Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Mon, 6 Jan 2025 14:25:19 +0800 Subject: [PATCH] make verify robust for padded archives [#200] --- pmtiles/verify.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pmtiles/verify.go b/pmtiles/verify.go index 20dd514..8124bba 100644 --- a/pmtiles/verify.go +++ b/pmtiles/verify.go @@ -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))