mirror of
https://github.com/transmission/transmission
synced 2025-03-08 21:04:25 +00:00
more banging on the fastresume-destination-directory thing. this permuation makes the fastresume destination a fallback, to be used only if the client didn't pass in a directory to tr_torrentInit*()
This commit is contained in:
parent
4104efbfbf
commit
bd01906f0c
3 changed files with 8 additions and 12 deletions
|
@ -320,10 +320,11 @@ tr_fastResumeSave( const tr_torrent * tor )
|
|||
}
|
||||
|
||||
static int
|
||||
loadDestination( tr_torrent * tor, FILE * fp )
|
||||
loadFallbackDestination( tr_torrent * tor, FILE * fp )
|
||||
{
|
||||
int pathlen = 0;
|
||||
char path[MAX_PATH_LENGTH];
|
||||
const int haveDestination = tor->destination && *tor->destination;
|
||||
|
||||
for( ;; ) {
|
||||
const int ch = fgetc( fp );
|
||||
|
@ -336,7 +337,7 @@ loadDestination( tr_torrent * tor, FILE * fp )
|
|||
|
||||
path[pathlen] = '\0';
|
||||
|
||||
if( pathlen ) {
|
||||
if( pathlen && !haveDestination ) {
|
||||
tr_free( tor->destination );
|
||||
tor->destination = tr_strdup( path );
|
||||
}
|
||||
|
@ -513,7 +514,6 @@ fastResumeLoadOld( tr_torrent * tor,
|
|||
|
||||
static uint64_t
|
||||
fastResumeLoadImpl ( tr_torrent * tor,
|
||||
const char * fallbackDestination,
|
||||
tr_bitfield * uncheckedPieces )
|
||||
{
|
||||
char path[MAX_PATH_LENGTH];
|
||||
|
@ -526,9 +526,6 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
assert( tor != NULL );
|
||||
assert( uncheckedPieces != NULL );
|
||||
|
||||
/* initialize the fallback values */
|
||||
tor->destination = tr_strdup( fallbackDestination );
|
||||
|
||||
/* Open resume file */
|
||||
fastResumeFileName( path, sizeof path, tor, 1 );
|
||||
file = fopen( path, "rb" );
|
||||
|
@ -621,7 +618,7 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
|
||||
case FR_ID_DESTINATION:
|
||||
{
|
||||
const int rret = loadDestination( tor, file );
|
||||
const int rret = loadFallbackDestination( tor, file );
|
||||
|
||||
if( rret && ( feof(file) || ferror(file) ) )
|
||||
{
|
||||
|
@ -751,10 +748,9 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
|
||||
uint64_t
|
||||
tr_fastResumeLoad( tr_torrent * tor,
|
||||
const char * fallbackDestination,
|
||||
tr_bitfield * uncheckedPieces )
|
||||
{
|
||||
const uint64_t ret = fastResumeLoadImpl( tor, fallbackDestination, uncheckedPieces );
|
||||
const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces );
|
||||
|
||||
if( ! ( ret & TR_FR_PROGRESS ) )
|
||||
tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount );
|
||||
|
|
|
@ -44,7 +44,6 @@ enum
|
|||
* Returns a bitwise-or'ed set of the data loaded from fastresume
|
||||
*/
|
||||
uint64_t tr_fastResumeLoad( tr_torrent * tor,
|
||||
const char * fallbackDestination,
|
||||
struct tr_bitfield * uncheckedPieces );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -269,6 +269,8 @@ torrentRealInit( tr_handle * h,
|
|||
|
||||
tr_globalLock( h );
|
||||
|
||||
tor->destination = tr_strdup( destination );
|
||||
|
||||
tor->handle = h;
|
||||
tor->pexDisabled = 0;
|
||||
|
||||
|
@ -339,8 +341,7 @@ torrentRealInit( tr_handle * h,
|
|||
|
||||
uncheckedPieces = tr_bitfieldNew( tor->info.pieceCount );
|
||||
|
||||
loaded = tr_fastResumeLoad( tor, destination, uncheckedPieces );
|
||||
|
||||
loaded = tr_fastResumeLoad( tor, uncheckedPieces );
|
||||
assert( tor->destination != NULL );
|
||||
|
||||
/* the `paused' flag has highest precedence...
|
||||
|
|
Loading…
Add table
Reference in a new issue