fix: do not load magnet file resume files (#2940)

This commit is contained in:
Charles Kerr 2022-04-17 21:55:20 -05:00 committed by GitHub
parent 1f17ab64be
commit af49e0f1af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

View File

@ -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();