Changeset 11811


Ignore:
Timestamp:
Feb 2, 2011, 6:06:09 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) minor code cleanup to inout.c's readOrWriteBytes().

Use ijuxda's suggestion of making the fstat(fd) call dependent on (fd>=0) rather than (!err).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r11709 r11811  
    137137    }
    138138
     139    /* check that the file corresponding to 'fd' still exists */
     140    if( fd >= 0 )
     141    {
     142        struct stat sb;
     143
     144        if( !fstat( fd, &sb ) && sb.st_nlink < 1 )
     145        {
     146            tr_torrentSetLocalError( tor, "Please Verify Local Data! A file disappeared: \"%s\"", file->name );
     147            err = ENOENT;
     148        }
     149    }
     150
    139151    if( !err )
    140152    {
    141         /* check & see if someone deleted the file while it was in our cache */
    142         struct stat sb;
    143         const tr_bool file_disappeared = fstat( fd, &sb ) || sb.st_nlink < 1;
    144         if( file_disappeared ) {
    145             tr_torrentSetLocalError( tor, "Please Verify Local Data! A file disappeared: \"%s\"", tor->info.files[fileIndex].name );
    146             err = ENOENT;
    147         }
    148 
    149153        if( ioMode == TR_IO_READ ) {
    150154            const int rc = tr_pread( fd, buf, buflen, fileOffset );
Note: See TracChangeset for help on using the changeset viewer.