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;
tr_free( r );
}
+static void torrentStart( tr_torrent * tor, int reloadProgress );
+
static void
torrentRealInit( tr_handle * h,
tr_torrent * tor,
tr_metainfoMigrate( h, &tor->info );
if( doStart )
- tr_torrentStart( tor );
+ torrentStart( tor, FALSE );
}
static int
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*
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 );
}
tr_globalUnlock( tor->handle );
}
+void
+tr_torrentStart( tr_torrent * tor )
+{
+ torrentStart( tor, TRUE );
+}
+
static void
torrentRecheckDoneImpl( void * vtor )
{
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];
}
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
{
* 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
{
for( ;; )
{
+ int changed = 0;
tr_file_index_t i;
tr_torrent * tor;
struct verify_node * node;
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 );
}
}