mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +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->doneDate = tor->doneDate;
|
||||||
s->startDate = tor->startDate;
|
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->corruptEver = tor->corruptCur + tor->corruptPrev;
|
||||||
s->downloadedEver = tor->downloadedCur + tor->downloadedPrev;
|
s->downloadedEver = tor->downloadedCur + tor->downloadedPrev;
|
||||||
s->uploadedEver = tor->uploadedCur + tor->uploadedPrev;
|
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. */
|
/** The last time we uploaded or downloaded piece data on this torrent. */
|
||||||
time_t activityDate;
|
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.
|
/** A torrent is considered finished if it has met its seed ratio.
|
||||||
As a result, only paused torrents can be finished. */
|
As a result, only paused torrents can be finished. */
|
||||||
tr_bool finished;
|
tr_bool finished;
|
||||||
|
|
|
@ -1479,16 +1479,7 @@ int trashDataFile(const char * filename)
|
||||||
|
|
||||||
- (NSInteger) stalledMinutes
|
- (NSInteger) stalledMinutes
|
||||||
{
|
{
|
||||||
const time_t start = fStat->startDate;
|
return fStat->idleSecs / 60;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isStalled
|
- (BOOL) isStalled
|
||||||
|
|
Loading…
Reference in a new issue