Changeset 45


Ignore:
Timestamp:
Jan 24, 2006, 4:43:47 AM (15 years ago)
Author:
joshe
Message:

Bump the resume file format and use it to save download and upload totals.

Location:
branches/oneport/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/oneport/libtransmission/fastresume.h

    r20 r45  
    2525 ***********************************************************************
    2626 * Format of the resume file:
    27  *  - 4 bytes: format version (currently 0)
     27 *  - 4 bytes: format version (currently 1)
     28 *  - 8 bytes: number of bytes downloaded
     29 *  - 8 bytes: number of bytes uploaded
    2830 *  - 4 bytes * number of files: mtimes of files
    2931 *  - 1 bit * number of blocks: whether we have the block or not
     
    3537 * All values are stored in the native endianness. Moving a
    3638 * libtransmission resume file from an architecture to another will not
    37  * work, although it will not hurt either (the mtimes will be wrong,
    38  * so the files will be scanned).
     39 * work, although it will not hurt either (the version will be wrong,
     40 * so the resume file will not be read).
    3941 **********************************************************************/
    4042
     
    98100   
    99101    FILE    * file;
    100     int       version = 0;
     102    int       version = 1;
    101103    char    * path;
    102104    int     * fileMTimes;
     
    124126    fwrite( &version, 4, 1, file );
    125127
     128    /* write download and upload totals */
     129    fwrite( &tor->downloaded[9], 8, 1, file );
     130    fwrite( &tor->uploaded[9], 8, 1, file );
     131
    126132    /* Write file mtimes */
    127133    fwrite( fileMTimes, 4, inf->fileCount, file );
     
    147153   
    148154    FILE    * file;
    149     int       version = 0;
     155    int       version = 1;
    150156    char    * path;
    151157    int     * fileMTimes1, * fileMTimes2;
     
    167173
    168174    /* Check the size */
    169     size = 4 + 4 * inf->fileCount + 4 * inf->pieceCount +
     175    size = 4 + 8 + 8 + 4 * inf->fileCount + 4 * inf->pieceCount +
    170176        ( tor->blockCount + 7 ) / 8;
    171177    fseek( file, 0, SEEK_END );
     
    188194        return 1;
    189195    }
     196
     197    /* read download and upload totals */
     198    fread( &tor->downloaded[9], 8, 1, file );
     199    fread( &tor->uploaded[9], 8, 1, file );
    190200
    191201    /* Compare file mtimes */
  • branches/oneport/libtransmission/transmission.c

    r43 r45  
    341341        tr_peerRem( tor, 0 );
    342342    }
    343 
    344     memset( tor->downloaded, 0, sizeof( tor->downloaded ) );
    345     memset( tor->uploaded,   0, sizeof( tor->uploaded ) );
    346343}
    347344
     
    611608static float rateDownload( tr_torrent_t * tor )
    612609{
     610    if( TR_STATUS_PAUSE & tor->status )
     611    {
     612        return 0.0;
     613    }
    613614    return rateGeneric( tor->dates, tor->downloaded );
    614615}
    615616static float rateUpload( tr_torrent_t * tor )
    616617{
     618    if( TR_STATUS_PAUSE & tor->status )
     619    {
     620        return 0.0;
     621    }
    617622    return rateGeneric( tor->dates, tor->uploaded );
    618623}
Note: See TracChangeset for help on using the changeset viewer.