fix: update package checksum computed from wrong package bytes#326
fix: update package checksum computed from wrong package bytes#326
Conversation
BuildPackageFile used a two-pass approach: hash the temp package (w/ empty-checksum manifest), then embed that hash and rebuild. The catalog stored the temp hash, but the actual file on disk had a different hash (different manifest content). This caused every update download checksum verification to fail. Fix: single-pass. The manifest Checksum field is never read during update, so the two-pass embedding was unnecessary.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 PR检查报告📋 检查概览
🧪 测试结果
📊 代码质量
📁 测试产物
🔗 相关链接此报告由GitHub Actions自动生成 |
Summary
Fix a checksum mismatch that caused every update download to fail with
System.IO.InvalidDataException: 更新包校验失败.Root Cause
BuildPackageFileinTelegramSearchBot.UpdateBuilderhad a two-pass design:manifest.Checksum = "", compute its SHA512 →tempHashtempHashinto the manifest, rebuild the package →finalBytestempHashin the catalog entry, but writefinalBytesto diskSince
finalByteshas a different manifest (containing the checksum), its actual SHA512 differs fromtempHash. The catalog records the wrong checksum, and the client'sVerifyPackageChecksumalways rejects the downloaded package.Fix
Single-pass approach. The manifest's
Checksumfield is never read during update (ExtractPackageToDirectoryskipsmanifest.json, and verification uses the catalog entry'sPackageChecksum). So skip the two-pass embedding entirely and compute SHA512 from the actual package bytes that get written to disk.Changes
TelegramSearchBot.UpdateBuilder/Program.csBuildPackageFile(): removed the temp package / two-pass logic, now creates the package once and hashes the final bytesSummary by CodeRabbit