Changeset 9341


Ignore:
Timestamp:
Oct 21, 2009, 5:03:10 AM (13 years ago)
Author:
charles
Message:

(trunk libT) add a couple of hooks for the mac client to use when migrating from its earlier move-on-complete code

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r9337 r9341  
    8383    const tr_bool doWrite = ioMode == TR_IO_WRITE;
    8484
    85     assert( tor->currentDir && *tor->currentDir );
    8685    assert( fileIndex < info->fileCount );
    8786    assert( !file->length || ( fileOffset < file->length ) );
     
    106105        if( !fileExists )
    107106        {
    108             base = tor->currentDir;
     107            base = tr_torrentGetCurrentDir( tor );
    109108
    110109            if( tr_sessionIsIncompleteFileNamingEnabled( tor->session ) )
  • trunk/libtransmission/torrent-ctor.c

    r8602 r9341  
    4444
    4545    struct optional_args    optionalArgs[2];
     46
     47    char                  * incompleteDir;
    4648
    4749    tr_file_index_t       * want;
     
    301303}
    302304
     305void
     306tr_ctorSetIncompleteDir( tr_ctor * ctor, const char * directory )
     307{
     308    tr_free( ctor->incompleteDir );
     309    ctor->incompleteDir = tr_strdup( directory );
     310}
     311
    303312int
    304313tr_ctorGetPeerLimit( const tr_ctor * ctor,
     
    306315                     uint16_t *      setmeCount )
    307316{
    308     int                          err = 0;
     317    int err = 0;
    309318    const struct optional_args * args = &ctor->optionalArgs[mode];
    310319
     
    345354    else if( setmeDownloadDir )
    346355        *setmeDownloadDir = args->downloadDir;
     356
     357    return err;
     358}
     359
     360int
     361tr_ctorGetIncompleteDir( const tr_ctor  * ctor,
     362                         const char    ** setmeIncompleteDir )
     363{
     364    int err = 0;
     365
     366    if( ctor->incompleteDir == NULL )
     367        err = 1;
     368    else
     369        *setmeIncompleteDir = ctor->incompleteDir;
    347370
    348371    return err;
     
    394417    tr_free( ctor->optionalArgs[1].downloadDir );
    395418    tr_free( ctor->optionalArgs[0].downloadDir );
     419    tr_free( ctor->incompleteDir );
    396420    tr_free( ctor->want );
    397421    tr_free( ctor->notWant );
  • trunk/libtransmission/torrent.c

    r9340 r9341  
    582582            tor->downloadDir = tr_strdup( dir );
    583583
     584    if( tr_ctorGetIncompleteDir( ctor, &dir ) )
     585        dir = tr_sessionGetIncompleteDir( session );
    584586    if( tr_sessionIsIncompleteDirEnabled( session ) )
    585         tor->incompleteDir = tr_strdup( tr_sessionGetIncompleteDir( session ) );
     587        tor->incompleteDir = tr_strdup( dir );
    586588
    587589    tor->lastPieceSize = info->totalSize % info->pieceSize;
     
    793795    return tor->downloadDir;
    794796}
     797
     798const char *
     799tr_torrentGetCurrentDir( const tr_torrent * tor )
     800{
     801    assert( tr_isTorrent( tor  ) );
     802
     803    return tor->currentDir;
     804}
     805
    795806
    796807void
  • trunk/libtransmission/transmission.h

    r9337 r9341  
    878878                                   const char * directory );
    879879
     880/**
     881 * @brief Set the incompleteDir for this torrent.
     882 *
     883 * This is not a supported API call.
     884 * It only exists so the mac client can migrate
     885 * its older incompleteDir settings, and that's
     886 * the only place where it should be used.
     887 */
     888void tr_ctorSetIncompleteDir( tr_ctor * ctor, const char * directory );
     889 
    880890/** Set whether or not the torrent begins downloading/seeding when created.
    881891    (Default: not paused) */
     
    906916                                   tr_ctorMode      mode,
    907917                                   const char    ** setmeDownloadDir );
     918
     919int         tr_ctorGetIncompleteDir( const tr_ctor  * ctor,
     920                                     const char    ** setmeIncompleteDir );
    908921
    909922int         tr_ctorGetMetainfo( const tr_ctor         * ctor,
     
    11431156
    11441157const char * tr_torrentGetDownloadDir( const tr_torrent * torrent );
     1158
     1159/**
     1160 * This returns the the root directory of where the torrent is.
     1161 *
     1162 * This will usually be the downloadDir.  However if the torrent
     1163 * has an incompleteDir enabled and hasn't finished downloading
     1164 * yet, that will be returned instead.
     1165 */
     1166const char * tr_torrentGetCurrentDir( const tr_torrent * tor );
    11451167
    11461168/**
Note: See TracChangeset for help on using the changeset viewer.