fix: add file integrity verification to prevent corrupted downloads #1327#1333
fix: add file integrity verification to prevent corrupted downloads #1327#1333Locon213 wants to merge 3 commits into
Conversation
Backend (Go): - Add SHA256, CRC32, fileSize, and integrityVerified fields to fetcher - Always compute file integrity hashes on download completion - Store integrity verification results for Stats API - Add tests for integrity verification functionality - Return error only when VerifyIntegrity config is enabled Frontend (Flutter): - Add getTaskStats API endpoint to fetch task statistics - Display integrity verification info in task detail drawer - Add HashInfoDialog modal for viewing hash information - Add security icon button in completed task cards to open hash info dialog - Add localization strings for hash info UI (en/ru) Files: - internal/protocol/http/fetcher.go: integrity verification implementation - internal/protocol/http/fetcher_test.go: add integrity verification tests - pkg/download/downloader_test.go: update tests - pkg/protocol/http/model.go: add Stats model fields - ui/flutter/lib/api/api.dart: add getTaskStats API - ui/flutter/lib/api/model/stats.dart: new Stats model - ui/flutter/lib/app/modules/task/views/task_view.dart: show integrity info - ui/flutter/lib/app/modules/task/views/hash_info_dialog.dart: new dialog - ui/flutter/lib/app/views/buid_task_list_view.dart: add hash info button - ui/flutter/lib/i18n/langs/*.dart: add localization strings Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1333 +/- ##
==========================================
- Coverage 71.21% 70.88% -0.33%
==========================================
Files 49 49
Lines 6566 6630 +64
==========================================
+ Hits 4676 4700 +24
- Misses 1460 1495 +35
- Partials 430 435 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for the PR and the effort you put into this! I appreciate the detailed implementation. However, I've decided not to merge this approach. After careful consideration, I feel that integrating file integrity verification as a built-in feature adds more complexity than it solves for the core use case. The hash computation on every completed download, the additional UI surface, the per-protocol config toggles, and the new API model all introduce ongoing maintenance burden that I'd prefer to avoid at this time. If file integrity checking is needed, I think it would be better suited as an extension/plugin rather than a core feature — that way users who need it can opt in without affecting the baseline download flow. Thanks again for your contribution! |
Summary
This PR addresses the issue where downloads sometimes result in corrupted archive files. The problem was reported in #1327, where user experienced SHA256 checksum mismatches when downloading files through Gopeed compared to browser downloads.
Problem
User reported that downloaded archive files were corrupted, with SHA256 checksums not matching the expected values. The same files downloaded through browser built-in downloaders were correct.
Solution
Implemented comprehensive file integrity verification with SHA256 and CRC32 hash computation for all downloads.
Changes
Backend (Go)
VerifyIntegrityconfiguration option for both HTTP and BT protocolsSha256field to HTTP stats andFileHashesmap to BT statsconnMulock through the entire read-check-write-update cycleVerifyIntegrityis enabled)VerifyIntegrityconfig is enabled and verification failsCrc32,FileSize,ExpectedSize,IntegrityVerifiedFrontend (Flutter)
verifyIntegritytoggle to HTTP and BT configuration settings UIStatsmodel and API endpoint (getTaskStats)HashInfoDialogmodal for viewing detailed hash informationKey Features
VerifyIntegrityto fail downloads that don't pass integrity checksTesting
TestFetcher_IntegrityVerificationto verify hash computation works correctlyTestFetcher_Statsto validate all integrity fieldsTestDownloader_Statsto verify integrity information is available through the APIRelated Issue
Closes #1327