From 54b394d160c80d0c20d16d9c5af743b2871dea6b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 27 Feb 2010 18:52:46 +0000 Subject: [PATCH] (trunk libT) #2984 "Transmission 1.91/OSX deletes completed download" -- experimental commit, and more debug messages --- libtransmission/torrent.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 324f07f7f..a66f89333 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -2424,6 +2424,31 @@ struct LocationData tr_torrent * tor; }; +static tr_bool +sameInode( const char * path1, const char * path2 ) +{ + int i1, i2; + struct stat s1, s2; + + s1.st_ino = 1; + i1 = stat( path1, &s1 ); + + s2.st_ino = 2; + i2 = stat( path2, &s2 ); + + if( !i1 && !i2 ) { + tr_dbg( "path1 inode is %"PRIu64"; path2 inode is %"PRIu64, + (uint64_t)s1.st_ino, + (uint64_t)s2.st_ino ); + return s1.st_ino == s2.st_ino; + } + + /* either one, or the other, or both don't exist... */ + tr_dbg( "stat(%s) returned %d\n", path1, i1 ); + tr_dbg( "stat(%s) returned %d\n", path2, i2 ); + return FALSE; +} + static void setLocation( void * vdata ) { @@ -2437,7 +2462,12 @@ setLocation( void * vdata ) assert( tr_isTorrent( tor ) ); - if( strcmp( location, tor->currentDir ) ) + tr_dbg( "Moving \"%s\" location from currentDir \"%s\" to \"%s\"", + tr_torrentName(tor), tor->currentDir, location ); + + tr_mkdirp( location, 0777 ); + + if( !sameInode( location, tor->currentDir ) ) { tr_file_index_t i; @@ -2465,6 +2495,8 @@ setLocation( void * vdata ) char * oldpath = tr_buildPath( oldbase, sub, NULL ); char * newpath = tr_buildPath( location, sub, NULL ); + tr_dbg( "Found file #%d: %s", (int)i, oldpath ); + if( do_move ) { tr_bool renamed = FALSE;