Changeset 1074


Ignore:
Timestamp:
Nov 10, 2006, 9:30:32 PM (15 years ago)
Author:
titer
Message:

Handle torrents with empty folders (fixes #12)

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fastresume.h

    r1060 r1074  
    9292            return 1;
    9393        }
    94         if( ( sb.st_mode & S_IFMT ) != S_IFREG )
     94        if( ( sb.st_mode & S_IFMT ) == S_IFREG )
    9595        {
    96             tr_err( "Wrong st_mode for '%s'", path );
    97             free( path );
    98             return 1;
     96#ifdef SYS_DARWIN
     97            tab[i] = ( sb.st_mtimespec.tv_sec & 0x7FFFFFFF );
     98#else
     99            tab[i] = ( sb.st_mtime & 0x7FFFFFFF );
     100#endif
     101        }
     102        else
     103        {
     104            /* Empty folder */
     105            tab[i] = 0;
    99106        }
    100107        free( path );
    101 
    102 #ifdef SYS_DARWIN
    103         tab[i] = ( sb.st_mtimespec.tv_sec & 0x7FFFFFFF );
    104 #else
    105         tab[i] = ( sb.st_mtime & 0x7FFFFFFF );
    106 #endif
    107108    }
    108109
  • trunk/libtransmission/inout.c

    r920 r1074  
    251251        }
    252252
     253        /* Empty folders use a dummy "" file, skip those */
     254        if( p == &path[strlen( path ) - 1] )
     255        {
     256            free( path );
     257            continue;
     258        }
     259
    253260        if( stat( path, &sb ) )
    254261        {
     
    434441        }
    435442
    436         /* Now let's get a stream on the file... */
    437         asprintf( &path, "%s/%s", tor->destination, inf->files[i].name );
    438         file = tr_fdFileOpen( tor->fdlimit, path );
    439         if( file < 0 )
    440         {
    441             tr_err( "readOrWriteBytes: could not open file '%s'", path );
     443        if( cur > 0 )
     444        {
     445            /* Now let's get a stream on the file... */
     446            asprintf( &path, "%s/%s", tor->destination, inf->files[i].name );
     447            file = tr_fdFileOpen( tor->fdlimit, path );
     448            if( file < 0 )
     449            {
     450                tr_err( "readOrWriteBytes: could not open file '%s'", path );
     451                free( path );
     452                goto fail;
     453            }
    442454            free( path );
    443             goto fail;
    444         }
    445         free( path );
    446 
    447         /* seek to the right offset... */
    448         if( lseek( file, offset, SEEK_SET ) < 0 )
    449         {
    450             goto fail;
    451         }
    452 
    453         /* do what we are here to do... */
    454         if( readOrWrite( file, buf, cur ) != cur )
    455         {
    456             goto fail;
    457         }
    458 
    459         /* and close the stream. */
    460         tr_fdFileRelease( tor->fdlimit, file );
     455
     456            /* seek to the right offset... */
     457            if( lseek( file, offset, SEEK_SET ) < 0 )
     458            {
     459                goto fail;
     460            }
     461
     462            /* do what we are here to do... */
     463            if( readOrWrite( file, buf, cur ) != cur )
     464            {
     465                goto fail;
     466            }
     467
     468            /* and close the stream. */
     469            tr_fdFileRelease( tor->fdlimit, file );
     470        }
    461471
    462472        /* 'cur' bytes done, 'size - cur' bytes to go with the next file */
Note: See TracChangeset for help on using the changeset viewer.