diff --git a/daemon/torrents.c b/daemon/torrents.c index dae59cd61..4416d4f33 100644 --- a/daemon/torrents.c +++ b/daemon/torrents.c @@ -497,19 +497,23 @@ opentor( const char * path, const char * hash, uint8_t * data, size_t size, return NULL; } + if( dir == NULL ) + dir = gl_dir; + if( NULL != path ) { - tor->tor = tr_torrentInit( gl_handle, path, tor->hash, + tor->tor = tr_torrentInit( gl_handle, path, dir, + tor->hash, TR_FLAG_SAVE, &errcode ); } else if( NULL != hash ) { - tor->tor = tr_torrentInitSaved( gl_handle, hash, 0, &errcode ); + tor->tor = tr_torrentInitSaved( gl_handle, hash, dir, 0, &errcode ); } else { - tor->tor = tr_torrentInitData( gl_handle, data, size, tor->hash, - TR_FLAG_SAVE, &errcode ); + tor->tor = tr_torrentInitData( gl_handle, data, size, dir, + tor->hash, TR_FLAG_SAVE, &errcode ); } if( NULL == tor->tor ) @@ -567,8 +571,6 @@ opentor( const char * path, const char * hash, uint8_t * data, size_t size, inf = tr_torrentInfo( tor->tor ); memcpy( tor->hash, inf->hash, sizeof tor->hash ); - tr_torrentSetFolder( tor->tor, ( NULL == dir ? gl_dir : dir ) ); - if( TR_FLAG_PRIVATE & inf->flags ) { tor->pexset = 1;