(trunk) #3675 "Not all .part files are removed" -- added patch for libtransmission and GTK+ client

This commit is contained in:
Charles Kerr 2010-12-16 03:38:07 +00:00
parent d40a60bd02
commit 821d315453
6 changed files with 65 additions and 30 deletions

View File

@ -1266,11 +1266,8 @@ tr_core_remove_torrent_from_id( TrCore * core, int id, gboolean deleteFiles )
/* remove from the gui */
gtk_list_store_remove( GTK_LIST_STORE( model ), &iter );
/* maybe delete the downloaded files */
if( deleteFiles )
tr_torrentDeleteLocalData( tor, gtr_file_trash_or_remove );
/* remove the torrent */
tr_torrent_set_delete_local_data_flag( gtor, deleteFiles );
tr_torrent_set_remove_flag( gtor, TRUE );
gtr_warn_if_fail( G_OBJECT( gtor )->ref_count == 1 );
g_object_unref( G_OBJECT( gtor ) ); /* remove the last refcount */

View File

@ -41,24 +41,22 @@ struct TrTorrentPrivate
{
tr_torrent * handle;
gboolean do_remove;
gboolean delete_local_data;
};
static void
tr_torrent_init( GTypeInstance * instance,
gpointer g_class UNUSED )
tr_torrent_init( GTypeInstance * instance, gpointer g_class UNUSED )
{
TrTorrent * self = TR_TORRENT( instance );
struct TrTorrentPrivate * p;
TrTorrent * self = TR_TORRENT( instance );
p = self->priv = G_TYPE_INSTANCE_GET_PRIVATE( self,
TR_TORRENT_TYPE,
struct TrTorrentPrivate );
p = G_TYPE_INSTANCE_GET_PRIVATE( self, TR_TORRENT_TYPE, struct TrTorrentPrivate );
p->handle = NULL;
p->do_remove = FALSE;
p->delete_local_data = FALSE;
#ifdef REFDBG
g_message( "torrent %p init", self );
#endif
self->priv = p;
}
static int
@ -78,7 +76,7 @@ tr_torrent_dispose( GObject * o )
if( self->priv->handle )
{
if( self->priv->do_remove )
tr_torrentRemove( self->priv->handle );
tr_torrentRemove( self->priv->handle, self->priv->delete_local_data, gtr_file_trash_or_remove );
else
tr_torrentFree( self->priv->handle );
}
@ -208,13 +206,20 @@ tr_torrent_new_ctor( tr_session * session,
}
void
tr_torrent_set_remove_flag( TrTorrent * gtor,
gboolean do_remove )
tr_torrent_set_remove_flag( TrTorrent * gtor, gboolean flag )
{
if( !isDisposed( gtor ) )
gtor->priv->do_remove = do_remove;
gtor->priv->do_remove = flag;
}
void
tr_torrent_set_delete_local_data_flag( TrTorrent * gtor, gboolean flag )
{
if( !isDisposed( gtor ) )
gtor->priv->delete_local_data = flag;
}
void
tr_torrent_open_folder( TrTorrent * gtor )
{

View File

@ -71,7 +71,9 @@ TrTorrent * tr_torrent_new_ctor( tr_session * session,
tr_ctor * ctor,
int * errcode );
void tr_torrent_set_remove_flag( TrTorrent *,
gboolean );
void tr_torrent_set_remove_flag( TrTorrent *, gboolean );
void tr_torrent_set_delete_local_data_flag( TrTorrent *, gboolean );
#endif

View File

@ -253,11 +253,12 @@ torrentRemove( tr_session * session,
{
tr_torrent * tor = torrents[i];
const tr_rpc_callback_status status = notify( session, TR_RPC_TORRENT_REMOVING, tor );
tr_bool deleteFlag;
if( tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag ) && deleteFlag )
tr_torrentDeleteLocalData( tor, NULL );
if( !( status & TR_RPC_NOREMOVE ) )
tr_torrentRemove( tor );
{
tr_bool deleteFlag = FALSE;
tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag );
tr_torrentRemove( tor, deleteFlag, NULL );
}
}
tr_free( torrents );

View File

@ -1750,13 +1750,41 @@ tr_torrentFree( tr_torrent * tor )
}
}
void
tr_torrentRemove( tr_torrent * tor )
struct remove_data
{
assert( tr_isTorrent( tor ) );
tr_torrent * tor;
tr_bool deleteFlag;
tr_fileFunc * deleteFunc;
};
static void
removeTorrent( void * vdata )
{
struct remove_data * data = vdata;
if( data->deleteFlag )
tr_torrentDeleteLocalData( data->tor, data->deleteFunc );
tr_torrentClearCompletenessCallback( data->tor );
closeTorrent( data->tor );
tr_free( data );
}
void
tr_torrentRemove( tr_torrent * tor,
tr_bool deleteFlag,
tr_fileFunc deleteFunc )
{
struct remove_data * data;
assert( tr_isTorrent( tor ) );
tor->isDeleting = 1;
tr_torrentFree( tor );
data = tr_new0( struct remove_data, 1 );
data->tor = tor;
data->deleteFlag = deleteFlag;
data->deleteFunc = deleteFunc;
tr_runInEventThread( tor->session, removeTorrent, data );
}
/**

View File

@ -1031,9 +1031,13 @@ tr_torrent * tr_torrentNew( const tr_ctor * ctor,
Running torrents are stopped first. */
void tr_torrentFree( tr_torrent * torrent );
typedef int tr_fileFunc( const char * filename );
/** @brief Removes our .torrent and .resume files for
this torrent, then calls tr_torrentFree(). */
void tr_torrentRemove( tr_torrent * torrent );
void tr_torrentRemove( tr_torrent * torrent,
tr_bool removeLocalData,
tr_fileFunc removeFunc );
/** @brief Start a torrent */
void tr_torrentStart( tr_torrent * torrent );
@ -1061,8 +1065,6 @@ void tr_torrentSetLocation( tr_torrent * torrent,
double * setme_progress,
int * setme_state );
typedef int tr_fileFunc( const char * filename );
/**
* @brief Deletes the torrent's local data.
* @param torrent