1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

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

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->addedDate = now; // this is a default that will be overwritten by the resume file
tor->anyDate = now; tor->anyDate = now;
// tr_resume::load() calls a lot of tr_torrentSetFoo() methods tr_resume::fields_t loaded = {};
// that set things as dirty, but... these settings being loaded are if (tor->hasMetainfo())
// 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_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(); tor->completeness = tor->completion.status();