~ubuntu-branches/ubuntu/quantal/transmission/quantal

« back to all changes in this revision

Viewing changes to libtransmission/torrent.c

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda, Krzysztof Klimonda, Chris Coulson
  • Date: 2010-03-03 02:55:26 UTC
  • mfrom: (1.1.34 upstream) (2.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100303025526-qcjmpnlvk9jv3y5o
Tags: 1.92-0ubuntu1
[ Krzysztof Klimonda ]
* New upstream release (LP: #538034), rebased on debian testing.
  Remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
      Can be removed in lucid+1
    + Added liblaunchpad-integration-dev and lsb-release to Build-Depends
  - debian/rules:
    + create a po template during package build.
  - debian/patches/01_lpi.patch:
    + integrate transmission with launchpad
  - debian/patches/20_add_x-ubuntu-gettext-domain.diff:
    + add x-ubuntu-gettext-domain to .desktop file.
  - debian/transmission-daemon.default:
    - remove --auth from OPTIONS
  - debian/control, debian/rules:
    + build transmission gtk+ client with both gconf and libcanberra support.
  - debian/patches/dont_build_libevent.patch:
    + disable libevent in configure.ac and Makefile.am because we use autotools
      to regenerate build files.
  - lucid/debian/patches/updateminiupnpcstrings_double_escape_slash.patch:
    + Deleted as the bug is fixed upstream
* Fixes bugs:
  - Fix directory selection error in GTK+ 2.19 (LP: #518692)
  - Transmission "Set Location" - dialog doesn't disappear (LP: #529037)
  - The "Torrent Options" dialog's Torrent Priority row gets too much
    vertical stretch (LP: #527299)
  - "Open Folder" behavior can be confusing for single-file torrents
    (LP: #505861)
* Refreshed 99_autoreconf.patch

[ Chris Coulson ]
* debian/patches/disable_web_ui.patch:
  - Disable the web UI by default again (LP: #542194)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * This exemption does not extend to derived works not owned by
8
8
 * the Transmission project.
9
9
 *
10
 
 * $Id: torrent.c 10250 2010-02-21 00:26:54Z charles $
 
10
 * $Id: torrent.c 10308 2010-03-06 22:33:45Z charles $
11
11
 */
12
12
 
13
13
#include <sys/types.h> /* stat */
834
834
{
835
835
    assert( tr_isTorrent( tor  ) );
836
836
 
837
 
    tr_announcerChangeMyPort( tor );
 
837
    if( tor->isRunning )
 
838
        tr_announcerChangeMyPort( tor );
838
839
}
839
840
 
840
841
static inline void
2344
2345
            deleteLocalFile( s[i], fileFunc );
2345
2346
 
2346
2347
    /* now blow away any remaining torrent files, such as torrent files in dirty folders */
2347
 
    for( f=0; f<tor->info.fileCount; ++f ) {
2348
 
        char * path = tr_buildPath( tor->currentDir, tor->info.files[f].name, NULL );
 
2348
    for( i=0, n=tr_ptrArraySize( &torrentFiles ); i<n; ++i ) {
 
2349
        char * path = tr_buildPath( tor->currentDir, tr_ptrArrayNth( &torrentFiles, i ), NULL );
2349
2350
        deleteLocalFile( path, fileFunc );
2350
2351
        tr_free( path );
2351
2352
    }
2424
2425
    tr_torrent * tor;
2425
2426
};
2426
2427
 
 
2428
static tr_bool
 
2429
sameInode( const char * path1, const char * path2 )
 
2430
{
 
2431
    int i1, i2;
 
2432
    struct stat s1, s2;
 
2433
 
 
2434
    s1.st_ino = 1;
 
2435
    i1 = stat( path1, &s1 );
 
2436
 
 
2437
    s2.st_ino = 2;
 
2438
    i2 = stat( path2, &s2 );
 
2439
 
 
2440
    if( !i1 && !i2 ) {
 
2441
        tr_dbg( "path1 inode is %"PRIu64"; path2 inode is %"PRIu64,
 
2442
                (uint64_t)s1.st_ino,
 
2443
                (uint64_t)s2.st_ino );
 
2444
        return s1.st_ino == s2.st_ino;
 
2445
    }
 
2446
 
 
2447
    /* either one, or the other, or both don't exist... */
 
2448
    tr_dbg( "stat(%s) returned %d\n", path1, i1 );
 
2449
    tr_dbg( "stat(%s) returned %d\n", path2, i2 );
 
2450
    return FALSE;
 
2451
}
 
2452
 
2427
2453
static void
2428
2454
setLocation( void * vdata )
2429
2455
{
2437
2463
 
2438
2464
    assert( tr_isTorrent( tor ) );
2439
2465
 
2440
 
    if( strcmp( location, tor->currentDir ) )
 
2466
    tr_dbg( "Moving \"%s\" location from currentDir \"%s\" to \"%s\"",
 
2467
            tr_torrentName(tor), tor->currentDir, location );
 
2468
 
 
2469
    tr_mkdirp( location, 0777 );
 
2470
 
 
2471
    if( !sameInode( location, tor->currentDir ) )
2441
2472
    {
2442
2473
        tr_file_index_t i;
2443
2474
 
2465
2496
                char * oldpath = tr_buildPath( oldbase, sub, NULL );
2466
2497
                char * newpath = tr_buildPath( location, sub, NULL );
2467
2498
 
 
2499
                tr_dbg( "Found file #%d: %s", (int)i, oldpath );
 
2500
 
2468
2501
                if( do_move )
2469
2502
                {
2470
2503
                    tr_bool renamed = FALSE;
2511
2544
        }
2512
2545
    }
2513
2546
 
 
2547
    if( !err && do_move )
 
2548
    {
 
2549
        tr_free( tor->incompleteDir );
 
2550
        tor->incompleteDir = NULL;
 
2551
        tor->currentDir = tor->downloadDir;
 
2552
    }
 
2553
 
2514
2554
    if( data->setme_state )
2515
2555
        *data->setme_state = err ? TR_LOC_ERROR : TR_LOC_DONE;
2516
2556