mirror of
https://github.com/transmission/transmission
synced 2025-03-04 18:48:06 +00:00
(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).
This commit is contained in:
parent
fc1c5fe553
commit
4736d863bf
1 changed files with 9 additions and 5 deletions
|
@ -136,16 +136,20 @@ readOrWriteBytes( tr_session * session,
|
|||
tr_free( subpath );
|
||||
}
|
||||
|
||||
if( !err )
|
||||
/* check that the file corresponding to 'fd' still exists */
|
||||
if( fd >= 0 )
|
||||
{
|
||||
/* check & see if someone deleted the file while it was in our cache */
|
||||
struct stat sb;
|
||||
const tr_bool file_disappeared = fstat( fd, &sb ) || sb.st_nlink < 1;
|
||||
if( file_disappeared ) {
|
||||
tr_torrentSetLocalError( tor, "Please Verify Local Data! A file disappeared: \"%s\"", tor->info.files[fileIndex].name );
|
||||
|
||||
if( !fstat( fd, &sb ) && sb.st_nlink < 1 )
|
||||
{
|
||||
tr_torrentSetLocalError( tor, "Please Verify Local Data! A file disappeared: \"%s\"", file->name );
|
||||
err = ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
if( !err )
|
||||
{
|
||||
if( ioMode == TR_IO_READ ) {
|
||||
const int rc = tr_pread( fd, buf, buflen, fileOffset );
|
||||
if( rc < 0 ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue