Ignore:
Timestamp:
Mar 3, 2011, 7:59:12 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) add an "existing dir" argument to tr_fdFileCheckout().

existing_dir: An ancestor of filename which must already exist and won't be created by tr_fdFileCheckout(). In implementation this is the download directory and prevents directories from being created in error, such as a mount point for an external drive when the drive is unplugged.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r11881 r12076  
    351351static int
    352352cached_file_open( struct tr_cached_file  * o,
     353                  const char             * existing_dir,
    353354                  const char             * filename,
    354355                  tr_bool                  writable,
     
    359360    struct stat sb;
    360361    tr_bool alreadyExisted;
     362
     363    /* confirm that existing_dir, if specified, exists on the disk */
     364    if( existing_dir && *existing_dir && stat( existing_dir, &sb ) )
     365    {
     366        const int err = errno;
     367        tr_err( _( "Couldn't open \"%1$s\": %2$s" ), existing_dir, tr_strerror( err ) );
     368        return err;
     369    }
    361370
    362371    /* create subfolders, if any */
     
    566575                   int                      torrent_id,
    567576                   tr_file_index_t          i,
     577                   const char             * existing_dir,
    568578                   const char             * filename,
    569579                   tr_bool                  writable,
     
    581591    if( !cached_file_is_open( o ) )
    582592    {
    583         const int err = cached_file_open( o, filename, writable, allocation, file_size );
     593        const int err = cached_file_open( o, existing_dir, filename, writable, allocation, file_size );
    584594        if( err ) {
    585595            errno = err;
Note: See TracChangeset for help on using the changeset viewer.