#912: Resume file parsed twice on startup
This commit is contained in:
parent
2cd2b35238
commit
ed4e902482
|
@ -205,11 +205,11 @@ addSingleTorrentDialog( GtkWindow * parent,
|
|||
gtk_table_attach( GTK_TABLE( t ), w, col, col+1, row, row+1, ~0, 0, 0, 0 );
|
||||
gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w );
|
||||
addTorrentFilters( GTK_FILE_CHOOSER( w ) );
|
||||
g_signal_connect( w, "selection-changed",
|
||||
G_CALLBACK( sourceChanged ), data );
|
||||
if( data->filename )
|
||||
if( !gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( w ), data->filename ) )
|
||||
g_warning( "couldn't select '%s'", data->filename );
|
||||
g_signal_connect( w, "selection-changed",
|
||||
G_CALLBACK( sourceChanged ), data );
|
||||
|
||||
++row;
|
||||
col = 0;
|
||||
|
|
|
@ -357,6 +357,8 @@ randomizeTiers( tr_info * info )
|
|||
tr_free( r );
|
||||
}
|
||||
|
||||
static void torrentStart( tr_torrent * tor, int reloadProgress );
|
||||
|
||||
static void
|
||||
torrentRealInit( tr_handle * h,
|
||||
tr_torrent * tor,
|
||||
|
@ -477,7 +479,7 @@ torrentRealInit( tr_handle * h,
|
|||
tr_metainfoMigrate( h, &tor->info );
|
||||
|
||||
if( doStart )
|
||||
tr_torrentStart( tor );
|
||||
torrentStart( tor, FALSE );
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -550,9 +552,12 @@ tr_torrentNew( tr_handle * handle,
|
|||
void
|
||||
tr_torrentSetFolder( tr_torrent * tor, const char * path )
|
||||
{
|
||||
tr_free( tor->destination );
|
||||
tor->destination = tr_strdup( path );
|
||||
tr_torrentSaveResume( tor );
|
||||
if( !path || !tor->destination || strcmp( path, tor->destination ) )
|
||||
{
|
||||
tr_free( tor->destination );
|
||||
tor->destination = tr_strdup( path );
|
||||
tr_torrentSaveResume( tor );
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
|
@ -998,14 +1003,15 @@ checkAndStartCB( tr_torrent * tor )
|
|||
tr_runInEventThread( tor->handle, checkAndStartImpl, tor );
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentStart( tr_torrent * tor )
|
||||
static void
|
||||
torrentStart( tr_torrent * tor, int reloadProgress )
|
||||
{
|
||||
tr_globalLock( tor->handle );
|
||||
|
||||
if( !tor->isRunning )
|
||||
{
|
||||
tr_torrentLoadResume( tor, TR_FR_PROGRESS, NULL );
|
||||
if( reloadProgress )
|
||||
tr_torrentLoadResume( tor, TR_FR_PROGRESS, NULL );
|
||||
tor->isRunning = 1;
|
||||
tr_verifyAdd( tor, checkAndStartCB );
|
||||
}
|
||||
|
@ -1013,6 +1019,12 @@ tr_torrentStart( tr_torrent * tor )
|
|||
tr_globalUnlock( tor->handle );
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentStart( tr_torrent * tor )
|
||||
{
|
||||
torrentStart( tor, TRUE );
|
||||
}
|
||||
|
||||
static void
|
||||
torrentRecheckDoneImpl( void * vtor )
|
||||
{
|
||||
|
|
|
@ -56,12 +56,13 @@ static tr_lock* getVerifyLock( void )
|
|||
return lock;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
checkFile( tr_torrent * tor,
|
||||
tr_file_index_t fileIndex,
|
||||
int * abortFlag )
|
||||
{
|
||||
tr_piece_index_t i;
|
||||
int changed = FALSE;
|
||||
int nofile;
|
||||
struct stat sb;
|
||||
char path[MAX_PATH_LENGTH];
|
||||
|
@ -78,11 +79,14 @@ checkFile( tr_torrent * tor,
|
|||
}
|
||||
else if( !tr_torrentIsPieceChecked( tor, i ) )
|
||||
{
|
||||
const int wasComplete = tr_cpPieceIsComplete( tor->completion, i );
|
||||
const tr_errno err = tr_ioTestPiece( tor, i );
|
||||
|
||||
if( !err ) /* yay */
|
||||
{
|
||||
tr_torrentSetHasPiece( tor, i, TRUE );
|
||||
if( !wasComplete )
|
||||
changed = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -91,13 +95,17 @@ checkFile( tr_torrent * tor,
|
|||
* it being incomplete, do nothing -- we don't
|
||||
* want to lose blocks in those incomplete pieces */
|
||||
|
||||
if( tr_cpPieceIsComplete( tor->completion, i ) )
|
||||
if( wasComplete ) {
|
||||
tr_torrentSetHasPiece( tor, i, FALSE );
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tr_torrentSetPieceChecked( tor, i, TRUE );
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -105,6 +113,7 @@ verifyThreadFunc( void * unused UNUSED )
|
|||
{
|
||||
for( ;; )
|
||||
{
|
||||
int changed = 0;
|
||||
tr_file_index_t i;
|
||||
tr_torrent * tor;
|
||||
struct verify_node * node;
|
||||
|
@ -127,13 +136,14 @@ verifyThreadFunc( void * unused UNUSED )
|
|||
|
||||
tr_torinf( tor, _( "Verifying torrent" ) );
|
||||
for( i=0; i<tor->info.fileCount && !stopCurrent; ++i )
|
||||
checkFile( tor, i, &stopCurrent );
|
||||
changed |= checkFile( tor, i, &stopCurrent );
|
||||
|
||||
tor->verifyState = TR_VERIFY_NONE;
|
||||
|
||||
if( !stopCurrent )
|
||||
{
|
||||
tr_torrentSaveResume( tor );
|
||||
if( changed )
|
||||
tr_torrentSaveResume( tor );
|
||||
fireCheckDone( tor, currentNode.verify_done_cb );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue