Changeset 3988


Ignore:
Timestamp:
Nov 26, 2007, 8:37:07 PM (15 years ago)
Author:
charles
Message:

plug in the stats.filesAdded field

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r3918 r3988  
    2828#include "platform.h"
    2929#include "peer-mgr.h"
     30#include "stats.h"
    3031#include "utils.h"
    3132
     
    5657    int fd = -1;
    5758    int ret;
     59    int fileExists;
    5860
    5961    assert( 0<=fileIndex && fileIndex<info->fileCount );
     
    6264
    6365    tr_buildPath ( path, sizeof(path), tor->destination, file->name, NULL );
     66    fileExists = !stat( path, &sb );
    6467
    6568    if( !file->length )
    6669        return 0;
    67     else if ((ioMode==TR_IO_READ) && stat( path, &sb ) ) /* does file exist? */
     70    else if ((ioMode==TR_IO_READ) && !fileExists ) /* does file exist? */
    6871        ret = tr_ioErrorFromErrno ();
    6972    else if ((fd = tr_fdFileCheckout ( path, ioMode==TR_IO_WRITE )) < 0)
     
    7578    else
    7679        ret = TR_OK;
     80
     81    if((ret==TR_OK) && (ioMode==TR_IO_WRITE) && !fileExists )
     82        tr_statsFileCreated( tor->handle );
    7783 
    7884    if( fd >= 0 )
  • trunk/libtransmission/stats.c

    r3987 r3988  
    174174
    175175void
    176 tr_torrentAdded( tr_handle * handle, const tr_torrent * torrent )
     176tr_statsFileCreated( tr_handle * handle )
    177177{
    178178    struct tr_stats_handle * stats = handle->sessionStats;
    179     stats->cumulative.filesAdded += torrent->info.fileCount;
    180     stats->single.filesAdded += torrent->info.fileCount;
     179    ++stats->cumulative.filesAdded;
     180    ++stats->single.filesAdded;
    181181}
  • trunk/libtransmission/stats.h

    r3983 r3988  
    2222void tr_statsAddDownloaded( tr_handle * handle, uint32_t bytes );
    2323
    24 void tr_torrentAdded( tr_handle * handle, const tr_torrent * torrent );
     24void tr_statsFileCreated( tr_handle * handle );
    2525
    2626#endif
Note: See TracChangeset for help on using the changeset viewer.