(trunk libT) #3136 "slashes in magnet names" -- fixed in trunk for 2.00

This commit is contained in:
Charles Kerr 2010-04-20 23:14:00 +00:00
parent e648c6d64f
commit 3682466488
4 changed files with 32 additions and 13 deletions

View File

@ -34,15 +34,31 @@
****
***/
char*
tr_metainfoGetBasename( const tr_info * inf )
{
char *ret, *pch, *name;
name = tr_strdup( inf->name );
for( pch=name; pch && *pch; ++pch )
if( *pch == '/' )
*pch = '_';
ret = tr_strdup_printf( "%s.%16.16s", name, inf->hashString );
tr_free( name );
return ret;
}
static char*
getTorrentFilename( const tr_session * session,
const tr_info * inf )
{
return tr_strdup_printf( "%s%c%s.%16.16s.torrent",
tr_getTorrentDir( session ),
TR_PATH_DELIMITER,
inf->name,
inf->hashString );
char * base = tr_metainfoGetBasename( inf );
char * filename = tr_strdup_printf( "%s" TR_PATH_DELIMITER_STR "%s.torrent",
tr_getTorrentDir( session ), base );
tr_free( base );
return filename;
}
static char*

View File

@ -34,5 +34,7 @@ void tr_metainfoRemoveSaved( const tr_session * session,
void tr_metainfoMigrate( tr_session * session,
tr_info * inf );
char* tr_metainfoGetBasename( const tr_info * );
#endif

View File

@ -17,8 +17,9 @@
#include "transmission.h"
#include "bencode.h"
#include "completion.h"
#include "metainfo.h" /* tr_metainfoGetBasename() */
#include "peer-mgr.h" /* pex */
#include "platform.h" /* tr_getResumeDir */
#include "platform.h" /* tr_getResumeDir() */
#include "resume.h"
#include "session.h"
#include "torrent.h"
@ -67,11 +68,11 @@ enum
static char*
getResumeFilename( const tr_torrent * tor )
{
return tr_strdup_printf( "%s%c%s.%16.16s.resume",
tr_getResumeDir( tor->session ),
TR_PATH_DELIMITER,
tr_torrentName( tor ),
tor->info.hashString );
char * base = tr_metainfoGetBasename( tr_torrentInfo( tor ) );
char * filename = tr_strdup_printf( "%s" TR_PATH_DELIMITER_STR "%s.resume",
tr_getResumeDir( tor->session ), base );
tr_free( base );
return filename;
}
/***

View File

@ -75,8 +75,8 @@ tr_torrentSetMetadataSizeHint( tr_torrent * tor, int size )
{
int i;
struct tr_incomplete_metadata * m;
int n = ( size + ( METADATA_PIECE_SIZE - 1 ) ) / METADATA_PIECE_SIZE;
dbgmsg( tor, "there are %d pieces", n );
const int n = ( size + ( METADATA_PIECE_SIZE - 1 ) ) / METADATA_PIECE_SIZE;
dbgmsg( tor, "metadata is %d bytes in %d pieces", size, n );
m = tr_new( struct tr_incomplete_metadata, 1 );
m->pieceCount = n;