Changeset 6016


Ignore:
Timestamp:
Jun 3, 2008, 7:16:12 PM (14 years ago)
Author:
charles
Message:

(1) add a doneDate to tr_torrent and tr_stat. (2) save tr_torrent.doneDate and tr_torrent.activityDate between sessions in the .resume file.

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/resume.c

    r5994 r6016  
    2525#include "utils.h" /* tr_buildPath */
    2626
    27 #define KEY_CORRUPT      "corrupt"
    28 #define KEY_DOWNLOAD_DIR "destination"
    29 #define KEY_DND          "dnd"
    30 #define KEY_DOWNLOADED   "downloaded"
    31 #define KEY_MAX_PEERS    "max-peers"
    32 #define KEY_PAUSED       "paused"
    33 #define KEY_PEERS        "peers"
    34 #define KEY_PRIORITY     "priority"
    35 #define KEY_PROGRESS     "progress"
    36 #define KEY_SPEEDLIMIT   "speed-limit"
    37 #define KEY_UPLOADED     "uploaded"
    38 #define KEY_ADDED_DATE   "added-date"
     27#define KEY_ACTIVITY_DATE   "activity-date"
     28#define KEY_ADDED_DATE      "added-date"
     29#define KEY_CORRUPT         "corrupt"
     30#define KEY_DONE_DATE       "done-date"
     31#define KEY_DOWNLOAD_DIR    "destination"
     32#define KEY_DND             "dnd"
     33#define KEY_DOWNLOADED      "downloaded"
     34#define KEY_MAX_PEERS       "max-peers"
     35#define KEY_PAUSED          "paused"
     36#define KEY_PEERS           "peers"
     37#define KEY_PRIORITY        "priority"
     38#define KEY_PROGRESS        "progress"
     39#define KEY_SPEEDLIMIT      "speed-limit"
     40#define KEY_UPLOADED        "uploaded"
    3941
    4042#define KEY_SPEEDLIMIT_DOWN_SPEED "down-speed"
     
    348350    char filename[MAX_PATH_LENGTH];
    349351
    350     tr_bencInitDict( &top, 12 );
     352    tr_bencInitDict( &top, 14 );
     353    tr_bencDictAddInt( &top, KEY_ACTIVITY_DATE,
     354                             tor->activityDate );
     355    tr_bencDictAddInt( &top, KEY_ADDED_DATE,
     356                             tor->addedDate );
    351357    tr_bencDictAddInt( &top, KEY_CORRUPT,
    352358                             tor->corruptPrev + tor->corruptCur );
     359    tr_bencDictAddInt( &top, KEY_DONE_DATE,
     360                             tor->doneDate );
    353361    tr_bencDictAddStr( &top, KEY_DOWNLOAD_DIR,
    354362                             tor->downloadDir );
     
    361369    tr_bencDictAddInt( &top, KEY_PAUSED,
    362370                             tor->isRunning ? 0 : 1 );
    363     tr_bencDictAddInt( &top, KEY_ADDED_DATE,
    364                              tor->addedDate );
    365371    savePeers( &top, tor );
    366372    savePriorities( &top, tor );
     
    445451        tor->addedDate = i;
    446452        fieldsLoaded |= TR_FR_ADDED_DATE;
     453    }
     454
     455    if( ( fieldsToLoad & TR_FR_DONE_DATE )
     456        && tr_bencDictFindInt( &top, KEY_DONE_DATE, &i ) ) {
     457        tor->doneDate = i;
     458        fieldsLoaded |= TR_FR_DONE_DATE;
     459    }
     460
     461    if( ( fieldsToLoad & TR_FR_ACTIVITY_DATE )
     462        && tr_bencDictFindInt( &top, KEY_ACTIVITY_DATE, &i ) ) {
     463        tor->activityDate = i;
     464        fieldsLoaded |= TR_FR_ACTIVITY_DATE;
    447465    }
    448466
  • trunk/libtransmission/resume.h

    r5994 r6016  
    1616enum
    1717{
    18   TR_FR_DOWNLOADED    = (1<<0),
    19   TR_FR_UPLOADED      = (1<<1),
    20   TR_FR_CORRUPT       = (1<<2),
    21   TR_FR_PEERS         = (1<<3),
    22   TR_FR_PROGRESS      = (1<<4),
    23   TR_FR_DND           = (1<<5),
    24   TR_FR_PRIORITY      = (1<<6),
    25   TR_FR_SPEEDLIMIT    = (1<<7),
    26   TR_FR_RUN           = (1<<8),
    27   TR_FR_DOWNLOAD_DIR  = (1<<9),
    28   TR_FR_MAX_PEERS     = (1<<10),
    29   TR_FR_ADDED_DATE    = (1<<11)
     18  TR_FR_DOWNLOADED     = (1<<0),
     19  TR_FR_UPLOADED       = (1<<1),
     20  TR_FR_CORRUPT        = (1<<2),
     21  TR_FR_PEERS          = (1<<3),
     22  TR_FR_PROGRESS       = (1<<4),
     23  TR_FR_DND            = (1<<5),
     24  TR_FR_PRIORITY       = (1<<6),
     25  TR_FR_SPEEDLIMIT     = (1<<7),
     26  TR_FR_RUN            = (1<<8),
     27  TR_FR_DOWNLOAD_DIR   = (1<<9),
     28  TR_FR_MAX_PEERS      = (1<<10),
     29  TR_FR_ADDED_DATE     = (1<<11),
     30  TR_FR_DONE_DATE      = (1<<12),
     31  TR_FR_ACTIVITY_DATE  = (1<<13)
    3032};
    3133
  • trunk/libtransmission/torrent.c

    r5994 r6016  
    738738    s->swarmSpeed = tr_rcRate( tor->swarmSpeed );
    739739   
    740     s->startDate = tor->startDate;
    741740    s->activityDate = tor->activityDate;
    742     s->addedDate = tor->addedDate;
     741    s->addedDate    = tor->addedDate;
     742    s->doneDate     = tor->doneDate;
     743    s->startDate    = tor->startDate;
    743744
    744745    s->corruptEver     = tor->corruptCur    + tor->corruptPrev;
     
    11911192
    11921193        if( recentChange && ( cpStatus == TR_CP_COMPLETE ) )
     1194        {
    11931195            tr_trackerCompleted( tor->tracker );
     1196
     1197            tor->doneDate = time( NULL );
     1198        }
    11941199
    11951200        tr_torrentSaveResume( tor );
  • trunk/libtransmission/torrent.h

    r5994 r6016  
    161161
    162162    time_t                     addedDate;
     163    time_t                     activityDate;
     164    time_t                     doneDate;
    163165    time_t                     startDate;
    164     time_t                     activityDate;
    165166
    166167    tr_torrent_status_func   * status_func;
  • trunk/libtransmission/transmission.h

    r6004 r6016  
    12211221    /** When the torrent was first added. */
    12221222    time_t addedDate;
     1223
     1224    /** When the torrent finished downloading. */
     1225    time_t doneDate;
    12231226   
    12241227    /** When the torrent was last started. */
Note: See TracChangeset for help on using the changeset viewer.