fix magnet link start logic (#4528)

This commit is contained in:
SweetPPro 2023-02-02 17:19:20 +11:00 committed by GitHub
parent 0493542f62
commit 1e988c9ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 2 deletions

View File

@ -312,7 +312,7 @@ void on_have_all_metainfo(tr_torrent* tor, tr_incomplete_metadata* m)
tor->incompleteMetadata = nullptr;
tor->isStopping = true;
tor->magnetVerify = true;
if (tor->session->shouldPauseAddedTorrents())
if (tor->session->shouldPauseAddedTorrents() && !tor->magnetStartAfterVerify)
{
tor->startAfterVerify = false;
}

View File

@ -1782,6 +1782,16 @@ void tr_torrentStartNow(tr_torrent* tor)
}
}
void tr_torrentStartMagnet(tr_torrent* tor)
{
if (tr_isTorrent(tor))
{
tor->magnetStartAfterVerify = true;
tor->startAfterVerify = true;
torrentStart(tor, {});
}
}
// ---
namespace

View File

@ -904,6 +904,7 @@ public:
bool isRunning = false;
bool isStopping = false;
bool startAfterVerify = false;
bool magnetStartAfterVerify = false;
bool magnetVerify = false;

View File

@ -601,6 +601,9 @@ void tr_sessionSetAntiBruteForceEnabled(tr_session* session, bool enabled);
/** @brief Like `tr_torrentStart()`, but resumes right away regardless of the queues. */
void tr_torrentStartNow(tr_torrent* tor);
/** @brief Like tr_torrentStart(), but sets magnetStartAfterVerify to true. */
void tr_torrentStartMagnet(tr_torrent*);
/** @brief Return the queued torrent's position in the queue it's in. [0...n) */
size_t tr_torrentGetQueuePosition(tr_torrent const* tor);

View File

@ -225,7 +225,7 @@ typedef NS_ENUM(NSUInteger, PopupPriority) {
if (self.fStartCheck.state == NSControlStateValueOn)
{
[self.torrent startTransfer];
[self.torrent startMagnetTransferAfterMetaDownload];
}
[self close];

View File

@ -43,6 +43,7 @@ extern NSString* const kTorrentDidChangeGroupNotification;
- (void)startTransferIgnoringQueue:(BOOL)ignoreQueue;
- (void)startTransferNoQueue;
- (void)startTransfer;
- (void)startMagnetTransferAfterMetaDownload;
- (void)stopTransfer;
- (void)startQueue;
- (void)sleep;

View File

@ -276,6 +276,18 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
[self startTransferIgnoringQueue:NO];
}
- (void)startMagnetTransferAfterMetaDownload
{
if ([self alertForRemainingDiskSpace])
{
tr_torrentStartMagnet(self.fHandle);
[self update];
//capture, specifically, stop-seeding settings changing to unlimited
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil];
}
}
- (void)stopTransfer
{
tr_torrentStop(self.fHandle);