diff --git a/NEWS b/NEWS index 7839d06bc..b82917db7 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ NEWS file for Transmission + Add Dutch localization, re-add Russian localization, fix Korean localization - gtk: + Fix 0.90 packaging errors + + Fix 0.90 assertion failure: "destination != (void*)0" 0.90 (2007/10/23) - Encryption support, with option to ignore unencrypted peers diff --git a/gtk/tr_core.c b/gtk/tr_core.c index 6af572b60..ea380956d 100644 --- a/gtk/tr_core.c +++ b/gtk/tr_core.c @@ -447,7 +447,7 @@ tr_core_load( TrCore * self, gboolean paused ) path = getdownloaddir( ); - torrents = tr_loadTorrents ( self->handle, NULL, paused, &count ); + torrents = tr_loadTorrents ( self->handle, path, paused, &count ); for( i=0; idestination && *tor->destination; for( ;; ) { const int ch = fgetc( fp ); @@ -347,10 +346,10 @@ loadFallbackDestination( tr_torrent * tor, FILE * fp ) path[pathlen] = '\0'; - if( pathlen && !haveDestination ) { - tr_free( tor->destination ); - tor->destination = tr_strdup( path ); - } + if( argIsFallback ) + tor->destination = tr_strdup( pathlen ? path : destination ); + else + tor->destination = tr_strdup( destination && *destination ? destination : path ); return TR_OK; } @@ -525,7 +524,9 @@ fastResumeLoadOld( tr_torrent * tor, static uint64_t fastResumeLoadImpl ( tr_torrent * tor, - tr_bitfield * uncheckedPieces ) + tr_bitfield * uncheckedPieces, + const char * destination, + int argIsFallback ) { char path[MAX_PATH_LENGTH]; FILE * file; @@ -629,7 +630,7 @@ fastResumeLoadImpl ( tr_torrent * tor, case FR_ID_DESTINATION: { - const int rret = loadFallbackDestination( tor, file ); + const int rret = loadDestination( tor, file, destination, argIsFallback ); if( rret && ( feof(file) || ferror(file) ) ) { @@ -772,12 +773,17 @@ fastResumeLoadImpl ( tr_torrent * tor, uint64_t tr_fastResumeLoad( tr_torrent * tor, - tr_bitfield * uncheckedPieces ) + tr_bitfield * uncheckedPieces, + const char * destination, + int argIsFallback ) { - const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces ); + const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces, destination, argIsFallback ); if( ! ( ret & TR_FR_PROGRESS ) ) tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount ); + if( !tor->destination ) + tor->destination = tr_strdup( destination ); + return ret; } diff --git a/libtransmission/fastresume.h b/libtransmission/fastresume.h index 6d1d9fb01..c27808e18 100644 --- a/libtransmission/fastresume.h +++ b/libtransmission/fastresume.h @@ -45,6 +45,8 @@ enum * Returns a bitwise-or'ed set of the data loaded from fastresume */ uint64_t tr_fastResumeLoad( tr_torrent * tor, - struct tr_bitfield * uncheckedPieces ); + struct tr_bitfield * uncheckedPieces, + const char * destination, + int destinationIsFallback ); #endif diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index b736a3fbe..906948a91 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -257,6 +257,7 @@ static void torrentRealInit( tr_handle * h, tr_torrent * tor, const char * destination, + int destinationIsFallback, int isPaused ) { int doStart; @@ -267,8 +268,6 @@ torrentRealInit( tr_handle * h, tr_globalLock( h ); - tor->destination = tr_strdup( destination ); - tor->handle = h; tor->pexDisabled = 0; @@ -339,7 +338,7 @@ torrentRealInit( tr_handle * h, uncheckedPieces = tr_bitfieldNew( tor->info.pieceCount ); - loaded = tr_fastResumeLoad( tor, uncheckedPieces ); + loaded = tr_fastResumeLoad( tor, uncheckedPieces, destination, destinationIsFallback ); assert( tor->destination != NULL ); /* the `paused' flag has highest precedence... @@ -449,12 +448,13 @@ tr_torrentParse( const tr_handle * h, return ret; } -tr_torrent * -tr_torrentInit( tr_handle * h, - const char * path, - const char * destination, - int isPaused, - int * error ) +static tr_torrent * +tr_torrentInitImpl( tr_handle * h, + const char * path, + const char * destination, + int destinationIsFallback, + int isPaused, + int * error ) { int val; int tmpError; @@ -469,12 +469,32 @@ tr_torrentInit( tr_handle * h, *error = TR_EOTHER; else { tr_metainfoParseFile( &tor->info, h->tag, path, TRUE ); - torrentRealInit( h, tor, destination, isPaused ); + torrentRealInit( h, tor, destination, destinationIsFallback, isPaused ); } return tor; } +tr_torrent * +tr_torrentInit( tr_handle * h, + const char * path, + const char * destination, + int isPaused, + int * error ) +{ + return tr_torrentInitImpl( h, path, destination, FALSE, isPaused, error ); +} + +tr_torrent * +tr_torrentLoad( tr_handle * h, + const char * metainfoFilename, + const char * destination, + int isPaused, + int * error ) +{ + return tr_torrentInitImpl( h, metainfoFilename, destination, TRUE, isPaused, error ); +} + int tr_torrentParseHash( const tr_handle * h, const char * hashStr, @@ -520,7 +540,7 @@ tr_torrentInitSaved( tr_handle * h, *error = TR_EOTHER; else { tr_metainfoParseHash( &tor->info, h->tag, hashStr ); - torrentRealInit( h, tor, destination, isPaused ); + torrentRealInit( h, tor, destination, FALSE, isPaused ); } return tor; @@ -573,7 +593,7 @@ tr_torrentInitData( tr_handle * h, *error = TR_EOTHER; else { tr_metainfoParseData( &tor->info, h->tag, data, size, TRUE ); - torrentRealInit( h, tor, destination, isPaused ); + torrentRealInit( h, tor, destination, FALSE, isPaused ); } return tor; @@ -1303,4 +1323,3 @@ tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length ) ret += length; return ret; } - diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index 53596cbdf..21a888714 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -327,7 +327,7 @@ tr_close( tr_handle * h ) tr_torrent ** tr_loadTorrents ( tr_handle * h, - const char * destination, + const char * fallbackDestination, int isPaused, int * setmeCount ) { @@ -350,7 +350,7 @@ tr_loadTorrents ( tr_handle * h, tr_torrent * tor; char path[MAX_PATH_LENGTH]; tr_buildPath( path, sizeof(path), torrentDir, d->d_name, NULL ); - tor = tr_torrentInit( h, path, destination, isPaused, NULL ); + tor = tr_torrentLoad( h, path, fallbackDestination, isPaused, NULL ); if( tor != NULL ) { tr_list_append( &list, tor ); n++; diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 9736b89d0..6002f45f1 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -307,7 +307,7 @@ void tr_close( tr_handle * ); * from the previous session. */ tr_torrent ** tr_loadTorrents ( tr_handle * h, - const char * destination, + const char * fallback_destination, int isPaused, int * setmeCount ); @@ -332,6 +332,15 @@ tr_torrent * tr_torrentInit( tr_handle * handle, int isPaused, int * setme_error ); +/* This is a stupid hack to fix #415. Probably I should fold all + * these torrent constructors into a single function that takes + * a function object to hold all these esoteric arguments. */ +tr_torrent * tr_torrentLoad( tr_handle * handle, + const char * metainfo_filename, + const char * fallback_destination, + int isPaused, + int * setme_error ); + typedef struct tr_info tr_info; /**