diff --git a/macosx/Controller.mm b/macosx/Controller.mm index d08e0669a..1aa5e0755 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -2823,7 +2823,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool //check status if (torrent.active && !torrent.checkingWaiting) { - BOOL const isActive = !torrent.stalled; + BOOL const isActive = torrent.transmitting; if (isActive) { std::atomic_fetch_add_explicit(activeRef, 1, std::memory_order_relaxed); diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 3b942970c..f18b34d46 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -127,7 +127,10 @@ extern NSString* const kTorrentDidChangeGroupNotification; @property(nonatomic, readonly) CGFloat availableDesired; +/// True if non-paused. Running. @property(nonatomic, getter=isActive, readonly) BOOL active; +/// True if downloading or uploading. +@property(nonatomic, getter=isTransmitting, readonly) BOOL transmitting; @property(nonatomic, getter=isSeeding, readonly) BOOL seeding; @property(nonatomic, getter=isChecking, readonly) BOOL checking; @property(nonatomic, getter=isCheckingWaiting, readonly) BOOL checkingWaiting; @@ -200,6 +203,7 @@ extern NSString* const kTorrentDidChangeGroupNotification; @property(nonatomic, readonly) NSInteger secondsSeeding; @property(nonatomic, readonly) NSInteger stalledMinutes; +/// True if the torrent is running, but has been idle for long enough to be considered stalled. @property(nonatomic, getter=isStalled, readonly) BOOL stalled; - (void)updateTimeMachineExclude; diff --git a/macosx/Torrent.mm b/macosx/Torrent.mm index ce1576079..a0ce20a50 100644 --- a/macosx/Torrent.mm +++ b/macosx/Torrent.mm @@ -264,12 +264,12 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error) - (void)update { //get previous stalled value before update - BOOL const wasStalled = self.fStat != NULL && self.stalled; + BOOL const wasTransmitting = self.fStat != NULL && self.transmitting; self.fStat = tr_torrentStat(self.fHandle); - //make sure the "active" filter is updated when stalled-ness changes - if (wasStalled != self.stalled) + //make sure the "active" filter is updated when transmitting changes + if (wasTransmitting != self.transmitting) { //posting asynchronously with coalescing to prevent stack overflow on lots of torrents changing state at the same time [NSNotificationQueue.defaultQueue enqueueNotification:[NSNotification notificationWithName:@"UpdateQueue" object:self] @@ -869,6 +869,12 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error) self.fStat->activity != TR_STATUS_SEED_WAIT; } +- (BOOL)isTransmitting +{ + return self.fStat->peersGettingFromUs > 0 || self.fStat->peersSendingToUs > 0 || self.fStat->webseedsSendingToUs > 0 || + self.fStat->activity == TR_STATUS_CHECK; +} + - (BOOL)isSeeding { return self.fStat->activity == TR_STATUS_SEED;