Skip to content

Quick fix for --downloader.verify assertion#18270

Merged
anacrolix merged 1 commit intomainfrom
anacrolix/downloader-verify-assertion
Dec 12, 2025
Merged

Quick fix for --downloader.verify assertion#18270
anacrolix merged 1 commit intomainfrom
anacrolix/downloader-verify-assertion

Conversation

@anacrolix
Copy link
Copy Markdown
Contributor

Fixes #18165. Proper fix is coming in #18180.

@anacrolix anacrolix merged commit 6982abd into main Dec 12, 2025
18 checks passed
@anacrolix anacrolix deleted the anacrolix/downloader-verify-assertion branch December 12, 2025 06:14
AskAlexSharov added a commit that referenced this pull request Mar 16, 2026
## Summary

- Moves `AddTorrentsFromDisk` call from `initDownloader` (at startup,
before any sync) to an `afterSnapshotDownload` callback invoked once the
snapshot sync stage completes on the first sync cycle.
- This eliminates false-positive incomplete torrent reports that
occurred because we were registering on-disk snapshots before the sync
stage had a chance to complete them.
- The `afterDownload` callback is threaded through `StageSnapshotsCfg`,
`NewDefaultStages`, and `NewPipelineStages` with a `nil` default so
callers that don't need it are unaffected.
- Incomplete snapshot warnings after this callback are now flagged as
unexpected (sync just finished), with a comment noting the
preverified-set edge case that remains unresolved.

## Background

Issue #19435 first identified this problem: `AddTorrentsFromDisk` was
being called before initial sync status was checked, causing old or
stale `.torrent` files on disk to interfere with the sync stage's
ability to fetch the correct (preverified) versions of snapshots.

PR #19316 by @Giulio2002 addressed a related symptom — converting the
fatal "snapshot already loaded with different infohash" error in
`addPreverifiedSnapshotForDownload` into a warning — but this was
treating a symptom rather than the root cause.

Other related changes to this area:
- PR #18056 — "Final downloader cleanup": Changed `AddTorrentsFromDisk`
to only add completed snapshots (anything incomplete is assumed a
mistake), and removed it as a default at startup.
- PR #18270 — "Quick fix for --downloader.verify assertion": Fixed a
panic in `addCompleteTorrentFromMetainfo` when called from
`AddTorrentsFromDisk` on already-completed files (#18165).
- PR #15043 — "Fix a collection of downloader, snapshot sync and torrent
related issues": Earlier broad fix addressing how disk-loaded torrents
interact with preverified snapshots.
- PR #16655 — "Require torrents added from disk to complete on
`downloader.verify`": Enforced completion check for disk-loaded torrents
during verify.

@mh0lt — please take a look, particularly at the scenario where extra
snapshots land on disk that weren't part of the sync set (e.g. after an
upgrade or downgrade that changes the preverified set).

---------

Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
lupin012 pushed a commit that referenced this pull request Mar 17, 2026
## Summary

- Moves `AddTorrentsFromDisk` call from `initDownloader` (at startup,
before any sync) to an `afterSnapshotDownload` callback invoked once the
snapshot sync stage completes on the first sync cycle.
- This eliminates false-positive incomplete torrent reports that
occurred because we were registering on-disk snapshots before the sync
stage had a chance to complete them.
- The `afterDownload` callback is threaded through `StageSnapshotsCfg`,
`NewDefaultStages`, and `NewPipelineStages` with a `nil` default so
callers that don't need it are unaffected.
- Incomplete snapshot warnings after this callback are now flagged as
unexpected (sync just finished), with a comment noting the
preverified-set edge case that remains unresolved.

## Background

Issue #19435 first identified this problem: `AddTorrentsFromDisk` was
being called before initial sync status was checked, causing old or
stale `.torrent` files on disk to interfere with the sync stage's
ability to fetch the correct (preverified) versions of snapshots.

PR #19316 by @Giulio2002 addressed a related symptom — converting the
fatal "snapshot already loaded with different infohash" error in
`addPreverifiedSnapshotForDownload` into a warning — but this was
treating a symptom rather than the root cause.

Other related changes to this area:
- PR #18056 — "Final downloader cleanup": Changed `AddTorrentsFromDisk`
to only add completed snapshots (anything incomplete is assumed a
mistake), and removed it as a default at startup.
- PR #18270 — "Quick fix for --downloader.verify assertion": Fixed a
panic in `addCompleteTorrentFromMetainfo` when called from
`AddTorrentsFromDisk` on already-completed files (#18165).
- PR #15043 — "Fix a collection of downloader, snapshot sync and torrent
related issues": Earlier broad fix addressing how disk-loaded torrents
interact with preverified snapshots.
- PR #16655 — "Require torrents added from disk to complete on
`downloader.verify`": Enforced completion check for disk-loaded torrents
during verify.

@mh0lt — please take a look, particularly at the scenario where extra
snapshots land on disk that weren't part of the sync set (e.g. after an
upgrade or downgrade that changes the preverified set).

---------

Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--downloader.verify asserts for already completed files

2 participants