Changeset 11538


Ignore:
Timestamp:
Dec 16, 2010, 3:38:07 AM (11 years ago)
Author:
charles
Message:

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

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r11522 r11538  
    12671267        gtk_list_store_remove( GTK_LIST_STORE( model ), &iter );
    12681268
    1269         /* maybe delete the downloaded files */
    1270         if( deleteFiles )
    1271             tr_torrentDeleteLocalData( tor, gtr_file_trash_or_remove );
    1272 
    12731269        /* remove the torrent */
     1270        tr_torrent_set_delete_local_data_flag( gtor, deleteFiles );
    12741271        tr_torrent_set_remove_flag( gtor, TRUE );
    12751272        gtr_warn_if_fail( G_OBJECT( gtor )->ref_count == 1 );
  • trunk/gtk/tr-torrent.c

    r10852 r11538  
    4242    tr_torrent *  handle;
    4343    gboolean      do_remove;
     44    gboolean      delete_local_data;
    4445};
    4546
    4647
    4748static void
    48 tr_torrent_init( GTypeInstance *  instance,
    49                  gpointer g_class UNUSED )
    50 {
    51     TrTorrent *               self = TR_TORRENT( instance );
     49tr_torrent_init( GTypeInstance * instance, gpointer g_class UNUSED )
     50{
    5251    struct TrTorrentPrivate * p;
    53 
    54     p = self->priv = G_TYPE_INSTANCE_GET_PRIVATE( self,
    55                                                   TR_TORRENT_TYPE,
    56                                                   struct TrTorrentPrivate );
     52    TrTorrent * self = TR_TORRENT( instance );
     53
     54    p = G_TYPE_INSTANCE_GET_PRIVATE( self, TR_TORRENT_TYPE, struct TrTorrentPrivate );
    5755    p->handle = NULL;
    58 
    59 #ifdef REFDBG
    60     g_message( "torrent %p init", self );
    61 #endif
     56    p->do_remove = FALSE;
     57    p->delete_local_data = FALSE;
     58
     59    self->priv = p;
    6260}
    6361
     
    7977        {
    8078            if( self->priv->do_remove )
    81                 tr_torrentRemove( self->priv->handle );
     79                tr_torrentRemove( self->priv->handle, self->priv->delete_local_data, gtr_file_trash_or_remove );
    8280            else
    8381                tr_torrentFree( self->priv->handle );
     
    209207
    210208void
    211 tr_torrent_set_remove_flag( TrTorrent * gtor,
    212                             gboolean    do_remove )
     209tr_torrent_set_remove_flag( TrTorrent * gtor, gboolean flag )
    213210{
    214211    if( !isDisposed( gtor ) )
    215         gtor->priv->do_remove = do_remove;
    216 }
     212        gtor->priv->do_remove = flag;
     213}
     214
     215void
     216tr_torrent_set_delete_local_data_flag( TrTorrent * gtor, gboolean flag )
     217{
     218    if( !isDisposed( gtor ) )
     219        gtor->priv->delete_local_data = flag;
     220}
     221
    217222
    218223void
  • trunk/gtk/tr-torrent.h

    r10505 r11538  
    7272                                    int         * errcode );
    7373
    74 void           tr_torrent_set_remove_flag( TrTorrent *,
    75                                            gboolean );
     74void tr_torrent_set_remove_flag( TrTorrent *, gboolean );
     75
     76void tr_torrent_set_delete_local_data_flag( TrTorrent *, gboolean );
     77
    7678
    7779#endif
  • trunk/libtransmission/rpcimpl.c

    r11415 r11538  
    254254        tr_torrent * tor = torrents[i];
    255255        const tr_rpc_callback_status status = notify( session, TR_RPC_TORRENT_REMOVING, tor );
    256         tr_bool deleteFlag;
    257         if( tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag ) && deleteFlag )
    258             tr_torrentDeleteLocalData( tor, NULL );
    259256        if( !( status & TR_RPC_NOREMOVE ) )
    260             tr_torrentRemove( tor );
     257        {
     258            tr_bool deleteFlag = FALSE;
     259            tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag );
     260            tr_torrentRemove( tor, deleteFlag, NULL );
     261        }
    261262    }
    262263
  • trunk/libtransmission/torrent.c

    r11537 r11538  
    17511751}
    17521752
    1753 void
    1754 tr_torrentRemove( tr_torrent * tor )
    1755 {
    1756     assert( tr_isTorrent( tor ) );
    1757 
     1753struct remove_data
     1754{
     1755    tr_torrent   * tor;
     1756    tr_bool        deleteFlag;
     1757    tr_fileFunc  * deleteFunc;
     1758};
     1759
     1760static void
     1761removeTorrent( void * vdata )
     1762{
     1763    struct remove_data * data = vdata;
     1764
     1765    if( data->deleteFlag )
     1766        tr_torrentDeleteLocalData( data->tor, data->deleteFunc );
     1767
     1768    tr_torrentClearCompletenessCallback( data->tor );
     1769    closeTorrent( data->tor );
     1770    tr_free( data );
     1771}
     1772
     1773void
     1774tr_torrentRemove( tr_torrent   * tor,
     1775                  tr_bool        deleteFlag,
     1776                  tr_fileFunc    deleteFunc )
     1777{
     1778    struct remove_data * data;
     1779
     1780    assert( tr_isTorrent( tor ) );
    17581781    tor->isDeleting = 1;
    1759     tr_torrentFree( tor );
     1782
     1783    data = tr_new0( struct remove_data, 1 );
     1784    data->tor = tor;
     1785    data->deleteFlag = deleteFlag;
     1786    data->deleteFunc = deleteFunc;
     1787    tr_runInEventThread( tor->session, removeTorrent, data );
    17601788}
    17611789
  • trunk/libtransmission/transmission.h

    r11524 r11538  
    10321032void tr_torrentFree( tr_torrent * torrent );
    10331033
     1034typedef int tr_fileFunc( const char * filename );
     1035
    10341036/** @brief Removes our .torrent and .resume files for
    10351037           this torrent, then calls tr_torrentFree(). */
    1036 void tr_torrentRemove( tr_torrent * torrent );
     1038void tr_torrentRemove( tr_torrent  * torrent,
     1039                       tr_bool       removeLocalData,
     1040                       tr_fileFunc   removeFunc );
    10371041
    10381042/** @brief Start a torrent */
     
    10611065                            double      * setme_progress,
    10621066                            int         * setme_state );
    1063 
    1064 typedef int tr_fileFunc( const char * filename );
    10651067
    10661068/**
Note: See TracChangeset for help on using the changeset viewer.