From 087a804b49a039fc6041f321c0fd9c4a4cc7e363 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 5 Nov 2021 00:06:19 -0500 Subject: [PATCH] fix: another piece priority fix (#2099) move initialization to later in torrent construction so that we can correctly check whether the torrent is done or not --- libtransmission/resume.cc | 2 +- libtransmission/torrent.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libtransmission/resume.cc b/libtransmission/resume.cc index fb416bf97..e886fd74b 100644 --- a/libtransmission/resume.cc +++ b/libtransmission/resume.cc @@ -900,7 +900,7 @@ static uint64_t loadFromFile(tr_torrent* tor, uint64_t fieldsToLoad, bool* didRe // Only load file priorities if we are actually downloading. // If we're a seed or partial seed, loading it is a waste of time. // NB: this is why loadProgress() comes before loadFilePriorities() - if (!tr_torrentIsSeed(tor) && (fieldsToLoad & TR_FR_FILE_PRIORITIES) != 0) + if ((tr_cpLeftUntilDone(&tor->completion) != 0) && (fieldsToLoad & TR_FR_FILE_PRIORITIES) != 0) { fieldsLoaded |= loadFilePriorities(&top, tor); } diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index 241c1589d..06c3d1ecf 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -785,8 +785,6 @@ static void torrentInitFromInfo(tr_torrent* tor) tr_cpConstruct(&tor->completion, tor); tr_torrentInitFilePieces(tor); - tor->completeness = tr_cpGetStatus(&tor->completion); - tr_torrentInitPiecePriorities(tor); } static void tr_torrentFireMetadataCompleted(tr_torrent* tor); @@ -909,6 +907,7 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor) tr_ctorInitTorrentPriorities(ctor, tor); tr_ctorInitTorrentWanted(ctor, tor); + tr_torrentInitPiecePriorities(tor); refreshCurrentDir(tor);