mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
Have libtransmission keep track of idle seconds. Use this value for determining the stalled minutes in the Mac code.
This commit is contained in:
parent
6f5c9dcafb
commit
235caa572b
3 changed files with 10 additions and 10 deletions
|
@ -1001,6 +1001,11 @@ tr_torrentStat( tr_torrent * tor )
|
|||
s->doneDate = tor->doneDate;
|
||||
s->startDate = tor->startDate;
|
||||
|
||||
if (s->activity == TR_STATUS_DOWNLOAD || s->activity == TR_STATUS_SEED)
|
||||
s->idleSecs = difftime(tr_time(), tor->anyDate);
|
||||
else
|
||||
s->idleSecs = -1;
|
||||
|
||||
s->corruptEver = tor->corruptCur + tor->corruptPrev;
|
||||
s->downloadedEver = tor->downloadedCur + tor->downloadedPrev;
|
||||
s->uploadedEver = tor->uploadedCur + tor->uploadedPrev;
|
||||
|
|
|
@ -1843,6 +1843,10 @@ typedef struct tr_stat
|
|||
/** The last time we uploaded or downloaded piece data on this torrent. */
|
||||
time_t activityDate;
|
||||
|
||||
/** Number of seconds since the last activity (or since started).
|
||||
-1 if activity is not seeding or downloading. */
|
||||
int idleSecs;
|
||||
|
||||
/** A torrent is considered finished if it has met its seed ratio.
|
||||
As a result, only paused torrents can be finished. */
|
||||
tr_bool finished;
|
||||
|
|
|
@ -1479,16 +1479,7 @@ int trashDataFile(const char * filename)
|
|||
|
||||
- (NSInteger) stalledMinutes
|
||||
{
|
||||
const time_t start = fStat->startDate;
|
||||
if (start == 0)
|
||||
return -1;
|
||||
|
||||
NSDate * started = [NSDate dateWithTimeIntervalSince1970: start],
|
||||
* activity = [self dateActivity];
|
||||
|
||||
NSDate * laterDate = activity ? [started laterDate: activity] : started;
|
||||
|
||||
return ABS([laterDate timeIntervalSinceNow]) / 60;
|
||||
return fStat->idleSecs / 60;
|
||||
}
|
||||
|
||||
- (BOOL) isStalled
|
||||
|
|
Loading…
Reference in a new issue