Ticket #2914: finish_dir_r10301.patch

File finish_dir_r10301.patch, 14.5 KB (added by er13, 12 years ago)
  • libtransmission/rpcimpl.c

     
    11821182        tr_sessionSetIncompleteDir( session, str );
    11831183    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, &boolVal ) )
    11841184        tr_sessionSetIncompleteDirEnabled( session, boolVal );
     1185    if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_FINISH_DIR, &str ) )
     1186        tr_sessionSetFinishDir( session, str );
     1187    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_FINISH_DIR_ENABLED, &boolVal ) )
     1188        tr_sessionSetFinishDirEnabled( session, boolVal );
    11851189    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, &i ) )
    11861190        tr_sessionSetPeerLimit( session, i );
    11871191    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_PEER_LIMIT_TORRENT, &i ) )
     
    12961300    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_LIMIT_TORRENT, tr_sessionGetPeerLimitPerTorrent( s ) );
    12971301    tr_bencDictAddStr ( d, TR_PREFS_KEY_INCOMPLETE_DIR, tr_sessionGetIncompleteDir( s ) );
    12981302    tr_bencDictAddBool( d, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, tr_sessionIsIncompleteDirEnabled( s ) );
     1303    tr_bencDictAddStr ( d, TR_PREFS_KEY_FINISH_DIR, tr_sessionGetFinishDir( s ) );
     1304    tr_bencDictAddBool( d, TR_PREFS_KEY_FINISH_DIR_ENABLED, tr_sessionIsFinishDirEnabled( s ) );
    12991305    tr_bencDictAddBool( d, TR_PREFS_KEY_PEX_ENABLED, tr_sessionIsPexEnabled( s ) );
    13001306    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, tr_sessionIsDHTEnabled( s ) );
    13011307    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_PORT, tr_sessionGetPeerPort( s ) );
  • libtransmission/transmission.h

     
    168168#define TR_PREFS_KEY_ENCRYPTION                 "encryption"
    169169#define TR_PREFS_KEY_INCOMPLETE_DIR             "incomplete-dir"
    170170#define TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED     "incomplete-dir-enabled"
     171#define TR_PREFS_KEY_FINISH_DIR                 "finish-dir"
     172#define TR_PREFS_KEY_FINISH_DIR_ENABLED         "finish-dir-enabled"
    171173#define TR_PREFS_KEY_LAZY_BITFIELD              "lazy-bitfield-enabled"
    172174#define TR_PREFS_KEY_MSGLEVEL                   "message-level"
    173175#define TR_PREFS_KEY_OPEN_FILE_LIMIT            "open-file-limit"
     
    383385
    384386
    385387/**
     388 * @brief set the per-session finish folder.
     389 *
     390 * When enabled (s. tr_sessionGetFinishDirEnabled()), torrents reached
     391 * their seed ratio will be moved to that directory.
     392 *
     393 * @see tr_sessionGetFinishDir()
     394 * @see tr_sessionSetFinishDirEnabled()
     395 * @see tr_sessionGetFinishDirEnabled()
     396 */
     397void tr_sessionSetFinishDir( tr_session * session, const char * dir );
     398
     399/** @brief get the per-session finish folder */
     400const char* tr_sessionGetFinishDir( const tr_session * session );
     401
     402/** @brief enable or disable use of the finish folder */
     403void tr_sessionSetFinishDirEnabled( tr_session * session, tr_bool );
     404
     405/** @brief get whether or not the finish folder is enabled */
     406tr_bool tr_sessionIsFinishDirEnabled( const tr_session * session );
     407
     408/**
    386409 * @brief When enabled, newly-created files will have ".part" appended
    387410 *        to their filename until the file is fully downloaded
    388411 *
  • libtransmission/session.c

     
    236236tr_sessionGetDefaultSettings( const char * configDir, tr_benc * d )
    237237{
    238238    char * incompleteDir = tr_buildPath( configDir, "Incomplete", NULL );
     239    char * finishDir = tr_buildPath( configDir, "Finish", NULL );
    239240
    240241    assert( tr_bencIsDict( d ) );
    241242
     
    248249    tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION,               TR_DEFAULT_ENCRYPTION );
    249250    tr_bencDictAddStr ( d, TR_PREFS_KEY_INCOMPLETE_DIR,           incompleteDir );
    250251    tr_bencDictAddBool( d, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED,   FALSE );
     252    tr_bencDictAddStr ( d, TR_PREFS_KEY_FINISH_DIR,               finishDir );
     253    tr_bencDictAddBool( d, TR_PREFS_KEY_FINISH_DIR_ENABLED,       FALSE );
    251254    tr_bencDictAddBool( d, TR_PREFS_KEY_LAZY_BITFIELD,            TRUE );
    252255    tr_bencDictAddInt ( d, TR_PREFS_KEY_MSGLEVEL,                 TR_MSG_INF );
    253256    tr_bencDictAddInt ( d, TR_PREFS_KEY_OPEN_FILE_LIMIT,          atoi( TR_DEFAULT_OPEN_FILE_LIMIT_STR ) );
     
    298301    tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV6,        TR_DEFAULT_BIND_ADDRESS_IPV6 );
    299302
    300303    tr_free( incompleteDir );
     304    tr_free( finishDir );
    301305}
    302306
    303307void
     
    314318    tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION,               s->encryptionMode );
    315319    tr_bencDictAddStr ( d, TR_PREFS_KEY_INCOMPLETE_DIR,           tr_sessionGetIncompleteDir( s ) );
    316320    tr_bencDictAddBool( d, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED,   tr_sessionIsIncompleteDirEnabled( s ) );
     321    tr_bencDictAddStr ( d, TR_PREFS_KEY_FINISH_DIR,               tr_sessionGetFinishDir( s ) );
     322    tr_bencDictAddBool( d, TR_PREFS_KEY_FINISH_DIR_ENABLED,       tr_sessionIsFinishDirEnabled( s ) );
    317323    tr_bencDictAddBool( d, TR_PREFS_KEY_LAZY_BITFIELD,            s->useLazyBitfield );
    318324    tr_bencDictAddInt ( d, TR_PREFS_KEY_MSGLEVEL,                 tr_getMessageLevel( ) );
    319325    tr_bencDictAddInt ( d, TR_PREFS_KEY_OPEN_FILE_LIMIT,          tr_fdGetFileLimit( s ) );
     
    679685        tr_sessionSetIncompleteDir( session, str );
    680686    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, &boolVal ) )
    681687        tr_sessionSetIncompleteDirEnabled( session, boolVal );
     688    if( tr_bencDictFindStr( settings, TR_PREFS_KEY_FINISH_DIR, &str ) )
     689        tr_sessionSetFinishDir( session, str );
     690    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_FINISH_DIR_ENABLED, &boolVal ) )
     691        tr_sessionSetFinishDirEnabled( session, boolVal );
    682692    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_RENAME_PARTIAL_FILES, &boolVal ) )
    683693        tr_sessionSetIncompleteFileNamingEnabled( session, boolVal );
    684694
     
    892902****
    893903***/
    894904
     905void
     906tr_sessionSetFinishDir( tr_session * session, const char * dir )
     907{
     908    assert( tr_isSession( session ) );
     909
     910    if( session->finishDir != dir )
     911    {
     912        tr_free( session->finishDir );
     913
     914        session->finishDir = tr_strdup( dir );
     915    }
     916}
     917
     918const char*
     919tr_sessionGetFinishDir( const tr_session * session )
     920{
     921    assert( tr_isSession( session ) );
     922
     923    return session->finishDir;
     924}
     925
     926void
     927tr_sessionSetFinishDirEnabled( tr_session * session, tr_bool b )
     928{
     929    assert( tr_isSession( session ) );
     930    assert( tr_isBool( b ) );
     931
     932    session->isFinishDirEnabled = b;
     933}
     934
     935tr_bool
     936tr_sessionIsFinishDirEnabled( const tr_session * session )
     937{
     938    assert( tr_isSession( session ) );
     939
     940    return session->isFinishDirEnabled;
     941}
     942
     943/***
     944****
     945***/
     946
    895947void*
    896948tr_sessionGetBuffer( tr_session * session )
    897949{
     
    16021654    tr_free( session->torrentDir );
    16031655    tr_free( session->downloadDir );
    16041656    tr_free( session->incompleteDir );
     1657    tr_free( session->finishDir );
    16051658    tr_free( session->proxy );
    16061659    tr_free( session->proxyUsername );
    16071660    tr_free( session->proxyPassword );
  • libtransmission/session.h

     
    111111    tr_bool                      isIncompleteFileNamingEnabled;
    112112    tr_bool                      isRatioLimited;
    113113    tr_bool                      isIncompleteDirEnabled;
     114    tr_bool                      isFinishDirEnabled;
    114115
    115116    tr_benc                      removedTorrents;
    116117
     
    151152    char *                       resumeDir;
    152153    char *                       torrentDir;
    153154    char *                       incompleteDir;
     155    char *                       finishDir;
    154156
    155157    tr_proxy_type                proxyType;
    156158    char *                       proxy;
  • libtransmission/torrent.c

     
    26082608            /* set to no ratio limit to allow easy restarting */
    26092609            tr_torrentSetRatioMode( tor, TR_RATIOLIMIT_UNLIMITED );
    26102610
     2611            /* move torrent to finish-dir if enabled */
     2612            if( tr_sessionIsFinishDirEnabled( tor->session ) )
     2613                tr_torrentSetLocation(tor, tr_sessionGetFinishDir( tor->session ), TRUE, NULL, NULL);
     2614
    26112615            /* maybe notify the client */
    26122616            if( tor->ratio_limit_hit_func != NULL )
    26132617                tor->ratio_limit_hit_func( tor, tor->ratio_limit_hit_func_user_data );
  • daemon/transmission-remote.1

     
    136136such as "\-g1,3-5" to add files #1, #3, #4, and #5 to the download list.
    137137.It Fl G Fl -no-get Ar all | file-index | files
    138138Mark file(s) for not downloading.
     139.It Fl -finish-dir Ar dir
     140Move torrents reached their seed ratio to
     141.Ar directory.
     142.It Fl -no-finish-dir
     143Don't move torrents reached their seed ratio to a different directory.
    139144.It Fl gsr Fl -global-seedratio Ar ratio
    140145All torrents, unless overridden by a per-torrent setting, should seed until a specific
    141146.Ar ratio
  • daemon/daemon.c

     
    7171    { 'C', "no-watch-dir", "Disable the watch-dir", "C", 0, NULL },
    7272    { 941, "incomplete-dir", "Where to store new torrents until they're complete", NULL, 1, "<directory>" },
    7373    { 942, "no-incomplete-dir", "Don't store incomplete torrents in a different location", NULL, 0, NULL },
     74    { 943, "finish-dir", "Where to move torrents after they reached a specific ratio", NULL, 1, "<directory>" },
     75    { 944, "no-finish-dir", "Don't move torrents to a different location after they reached a specific ratio", NULL, 0, NULL },
    7476    { 'd', "dump-settings", "Dump the settings and exit", "d", 0, NULL },
    7577    { 'e', "logfile", "Dump the log messages to this filename", "e", 1, "<filename>" },
    7678    { 'f', "foreground", "Run in the foreground instead of daemonizing", "f", 0, NULL },
     
    323325            case 942:
    324326                      tr_bencDictAddBool( &settings, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, FALSE );
    325327                      break;
     328            case 943: tr_bencDictAddStr( &settings, TR_PREFS_KEY_FINISH_DIR, optarg );
     329                      tr_bencDictAddBool( &settings, TR_PREFS_KEY_FINISH_DIR_ENABLED, TRUE );
     330                      break;
     331            case 944: tr_bencDictAddBool( &settings, TR_PREFS_KEY_FINISH_DIR_ENABLED, FALSE );
     332                      break;
    326333            case 'd': dumpSettings = TRUE;
    327334                      break;
    328335            case 'e': logfile = fopen( optarg, "a+" );
  • daemon/transmission-daemon.1

     
    5050Do not watch for new .torrent files.
    5151.It Fl B Fl -no-blocklist
    5252Disble blocklists.
     53.It Fl -finish-dir Ar dir
     54Move torrents reached their seed ratio to
     55.Ar directory.
     56.It Fl -no-finish-dir
     57Don't move torrents reached their seed ratio to a different directory.
    5358.It Fl f Fl -foreground
    5459Run in the foreground and print errors to stderr.
    5560.It Fl g Fl -config-dir Ar directory
  • daemon/remote.c

     
    7575    { 963, "blocklist-update",      "Blocklist update", NULL, 0, NULL },
    7676    { 'c', "incomplete-dir",        "Where to store new torrents until they're complete", "c", 1, "<dir>" },
    7777    { 'C', "no-incomplete-dir",     "Don't store incomplete torrents in a different location", "C", 0, NULL },
     78    { 943, "finish-dir",            "Where to move torrents after they reached a specific ratio", NULL, 1, "<directory>" },
     79    { 944, "no-finish-dir",         "Don't move torrents to a different location after they reached a specific ratio", NULL, 0, NULL },
    7880    { 'b', "debug",                 "Print debugging information", "b",  0, NULL },
    7981    { 'd', "downlimit",             "Set the maximum global download speed in KB/s", "d",  1, "<speed>" },
    8082    { 'D', "no-downlimit",          "Don't limit the global download speed", "D",  0, NULL },
     
    442444                tr_bencDictAddBool( args, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, FALSE );
    443445                break;
    444446
     447            case 943:
     448                tr_bencDictAddStr( &top, "method", "session-set" );
     449                tr_bencDictAddStr( args, TR_PREFS_KEY_FINISH_DIR, optarg );
     450                tr_bencDictAddBool( args, TR_PREFS_KEY_FINISH_DIR_ENABLED, TRUE );
     451                break;
     452
     453            case 944:
     454                tr_bencDictAddStr( &top, "method", "session-set" );
     455                tr_bencDictAddBool( args, TR_PREFS_KEY_FINISH_DIR_ENABLED, FALSE );
     456                break;
     457
    445458            case 'd':
    446459                tr_bencDictAddStr( &top, "method", "session-set" );
    447460                tr_bencDictAddInt( args, TR_PREFS_KEY_DSPEED, numarg( optarg ) );
  • doc/rpc-spec.txt

     
    403403   "encryption"               | string     "required", "preferred", "tolerated"
    404404   "incomplete-dir"           | string     path for incomplete torrents, when enabled
    405405   "incomplete-dir-enabled"   | boolean    true means keep torrents in incomplete-dir until done
     406   "finish-dir"               | string     path for torrents reached their seed limit, when enabled
     407   "finish-dir-enabled"       | boolean    true means move torrents reached their seed ratio to finish-dir
    406408   "peer-limit-global"        | number     maximum global number of peers
    407409   "peer-limit-per-torrent"   | number     maximum global number of peers
    408410   "pex-enabled"              | boolean    true means allow pex in public torrents
     
    585587         |         | yes       | torrent-get    | new trackerStats arg "lastAnnounceTimedOut"
    586588   ------+---------+-----------+----------------+-------------------------------
    587589   8     | 1.92    | yes       | torrent-get    | new trackerStats arg "lastScrapeTimedOut"
     590         |         | yes       | session-set    | new arg "finish-dir"
     591         |         | yes       | session-set    | new arg "finish-dir-enabled"