Changeset 2147


Ignore:
Timestamp:
Jun 18, 2007, 2:48:32 AM (15 years ago)
Author:
charles
Message:

fix zero-size file bug reported by BMW

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/libtransmission/torrent.c

    r2121 r2147  
    620620tr_torrentFileBytesCompleted ( const tr_torrent_t * tor, int fileIndex )
    621621{
    622     const tr_file_t * file = &tor->info.files[fileIndex];
    623     int firstBlock         =  file->offset                     / tor->blockSize;
    624     int firstBlockOffset   =  file->offset                     % tor->blockSize;
    625     int lastBlock          = (file->offset + file->length - 1) / tor->blockSize;
    626     int lastBlockOffset    = (file->offset + file->length - 1) % tor->blockSize;
     622    const tr_file_t * file     = &tor->info.files[fileIndex];
     623    const int firstBlock       =  file->offset / tor->blockSize;
     624    const int firstBlockOffset =  file->offset % tor->blockSize;
     625    const int lastOffset       =  file->length ? file->length-1 : 0;
     626    const int lastBlock        = (file->offset + lastOffset) / tor->blockSize;
     627    const int lastBlockOffset  = (file->offset + lastOffset) % % tor->blockSize;
    627628    size_t haveBytes = 0;
    628629
     
    10911092    file = &info->files[fileIndex];
    10921093    firstByte = file->offset;
    1093     lastByte = firstByte + file->length - 1;
     1094    lastByte = firstByte + (file->length ? file->length-1 : 0);
    10941095    file->firstPiece = getBytePiece( info, firstByte );
    10951096    file->lastPiece = getBytePiece( info, lastByte );
Note: See TracChangeset for help on using the changeset viewer.