Changeset 5066


Ignore:
Timestamp:
Feb 19, 2008, 5:03:56 AM (14 years ago)
Author:
charles
Message:

(gtk) #544: remove fast-resume cache when appropriate

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr_core.c

    r5064 r5066  
    609609
    610610    /* delete the torrent */
    611     tr_torrentRemoveSaved( tr_torrent_handle( gtor ) );
     611    tr_torrent_set_delete_flag( gtor, TRUE );
    612612    g_object_unref( G_OBJECT( gtor ) );
    613613}
  • trunk/gtk/tr_torrent.c

    r5065 r5066  
    4040{
    4141   tr_torrent * handle;
     42   gboolean do_delete;
    4243   gboolean seeding_cap_enabled;
    4344   gdouble seeding_cap; /* ratio to stop seeding at */
     
    7778    {
    7879        if( self->priv->handle )
    79             tr_torrentClose( self->priv->handle );
     80        {
     81            if( self->priv->do_delete )
     82                tr_torrentDelete( self->priv->handle );
     83            else
     84                tr_torrentClose( self->priv->handle );
     85        }
     86
    8087        self->priv = NULL;
    8188    }
     
    289296
    290297void
     298tr_torrent_set_delete_flag( TrTorrent * gtor, gboolean do_delete )
     299{
     300    if( !isDisposed( gtor ) )
     301        gtor->priv->do_delete = do_delete;
     302}
     303
     304void
    291305tr_torrent_delete_files( TrTorrent * gtor )
    292306{
  • trunk/gtk/tr_torrent.h

    r5064 r5066  
    9393tr_torrent_new_ctor( tr_handle * handle, tr_ctor * ctor, char ** err );
    9494
     95void
     96tr_torrent_set_delete_flag( TrTorrent *, gboolean );
     97
    9598#endif
  • trunk/libtransmission/fastresume.c

    r5065 r5066  
    710710    return ret;
    711711}
     712
     713void
     714tr_fastResumeRemove( const tr_torrent * tor )
     715{
     716    char path[MAX_PATH_LENGTH];
     717    const char * cacheDir = tr_getCacheDirectory ();
     718    const char * hash = tor->info.hashString;
     719
     720    if( tor->handle->tag )
     721    {
     722        char base[1024];
     723        snprintf( base, sizeof(base), "%s-%s", hash, tor->handle->tag );
     724        tr_buildPath( path, sizeof(path), cacheDir, base, NULL );
     725        unlink( path );
     726    }
     727    else
     728    {
     729        tr_buildPath( path, sizeof(path), cacheDir, hash, NULL );
     730        unlink( path );
     731    }
     732}
  • trunk/libtransmission/fastresume.h

    r4813 r5066  
    4949                            const tr_ctor       * ctor );
    5050
     51void tr_fastResumeRemove( const tr_torrent * tor );
     52
    5153#endif
  • trunk/libtransmission/torrent.c

    r5042 r5066  
    827827}
    828828
    829 void tr_torrentRemoveSaved( tr_torrent * tor )
     829void
     830tr_torrentRemoveSaved( tr_torrent * tor )
    830831{
    831832    tr_metainfoRemoveSaved( tor->info.hashString, tor->handle->tag );
     833
     834    tr_fastResumeRemove( tor );
    832835}
    833836
     
    10041007    tr_globalLock( tor->handle );
    10051008
    1006     saveFastResumeNow( tor );
     1009    if( !tor->isDeleting )
     1010        saveFastResumeNow( tor );
    10071011    tor->isRunning = 0;
    10081012    tr_runInEventThread( tor->handle, stopTorrent, tor );
     
    10181022    tor->isRunning = 0;
    10191023    stopTorrent( tor );
     1024    if( tor->isDeleting )
     1025        tr_torrentRemoveSaved( tor );
    10201026    freeTorrent( tor );
    10211027}
     
    10351041    }
    10361042}
     1043
     1044void
     1045tr_torrentDelete( tr_torrent * tor )
     1046{
     1047    tor->isDeleting = 1;
     1048    tr_torrentClose( tor );
     1049}
     1050
    10371051
    10381052/**
  • trunk/libtransmission/torrent.h

    r5042 r5066  
    154154    unsigned int               statCur : 1;
    155155    unsigned int               isRunning : 1;
     156    unsigned int               isDeleting : 1;
    156157
    157158    uint16_t                   maxConnectedPeers;
  • trunk/libtransmission/transmission.h

    r5034 r5066  
    588588 */
    589589void tr_torrentClose( tr_torrent * );
     590
     591/**
     592 * Like tr_torrentClose() but also deletes
     593 * the fastresume file and our copy of the
     594 * torrent file
     595 */
     596void tr_torrentDelete( tr_torrent * );
    590597
    591598/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.