From af49e0f1af556a2a9d293156fe7d7d09e3797375 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 17 Apr 2022 21:55:20 -0500 Subject: [PATCH] fix: do not load magnet file resume files (#2940) --- libtransmission/torrent.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index 378c65c89..42cd89ca2 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -730,18 +730,23 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor) tor->addedDate = now; // this is a default that will be overwritten by the resume file tor->anyDate = now; - // tr_resume::load() calls a lot of tr_torrentSetFoo() methods - // that set things as dirty, but... these settings being loaded are - // the same ones that would be saved back again, so don't let them - // affect the 'is dirty' flag. - auto const was_dirty = tor->isDirty; - bool resume_file_was_migrated = false; - auto const loaded = tr_resume::load(tor, tr_resume::All, ctor, &resume_file_was_migrated); - tor->isDirty = was_dirty; - - if (resume_file_was_migrated) + tr_resume::fields_t loaded = {}; + if (tor->hasMetainfo()) { - tr_torrent_metainfo::migrateFile(session->torrent_dir, tor->name(), tor->infoHashString(), ".torrent"sv); + // tr_resume::load() calls a lot of tr_torrentSetFoo() methods + // that set things as dirty, but... these settings being loaded are + // the same ones that would be saved back again, so don't let them + // affect the 'is dirty' flag. + auto const was_dirty = tor->isDirty; + + bool resume_file_was_migrated = false; + loaded = tr_resume::load(tor, tr_resume::All, ctor, &resume_file_was_migrated); + tor->isDirty = was_dirty; + + if (resume_file_was_migrated) + { + tr_torrent_metainfo::migrateFile(session->torrent_dir, tor->name(), tor->infoHashString(), ".torrent"sv); + } } tor->completeness = tor->completion.status();