Changeset 11300


Ignore:
Timestamp:
Oct 11, 2010, 9:27:31 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3614 "Can't save benc files under uClibc 0.9.31" -- on some systems, calling unlink() on a file that doesn't exist returns 0 instead of -1 + ENOENT... so don't rely on that test. Instead, call stat() before unlink()ing the file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r11271 r11300  
    16831683        if( write( fd, str, len ) == (ssize_t)len )
    16841684        {
     1685            struct stat sb;
     1686            const tr_bool already_exists = !stat( filename, &sb ) && S_ISREG( sb.st_mode );
     1687
    16851688            tr_fsync( fd );
    16861689            tr_close_file( fd );
    16871690
    1688             if( !unlink( filename ) || ( errno == ENOENT ) )
     1691            if( !already_exists || !unlink( filename ) )
    16891692            {
    16901693                tr_dbg( "Renaming \"%s\" as \"%s\"", tmp, filename );
Note: See TracChangeset for help on using the changeset viewer.