]> granicus.if.org Git - transmission/commitdiff
add more debugging messages for loading progress from the bencoded resume file
authorCharles Kerr <charles@transmissionbt.com>
Mon, 14 Apr 2008 20:30:43 +0000 (20:30 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Mon, 14 Apr 2008 20:30:43 +0000 (20:30 +0000)
libtransmission/resume.c
libtransmission/torrent.c

index 909405f75201c1cbedd418ae53c6005afa89fb14..5da71b6d7120591cd9c0e1286bf16fa36fa42e08 100644 (file)
@@ -242,8 +242,6 @@ loadSpeedLimits( tr_benc * dict, tr_torrent * tor )
 ****
 ***/
 
-static const time_t verifyNeeded = ~(time_t)0;
-
 static void
 saveProgress( tr_benc * dict, const tr_torrent * tor )
 {
@@ -261,9 +259,11 @@ saveProgress( tr_benc * dict, const tr_torrent * tor )
     /* add the mtimes */
     mtimes = tr_torrentGetMTimes( tor, &n );
     m = tr_bencDictAddList( p, KEY_PROGRESS_MTIMES, n );
-    for( i=0; i<n; ++i )
-        tr_bencListAddInt( m, tr_torrentIsFileChecked( tor, i )
-                              ? mtimes[i] : verifyNeeded );
+    for( i=0; i<n; ++i ) {
+        if( tr_torrentIsFileChecked( tor, i ) )
+            mtimes[i] = ~(time_t)0; /* force a recheck */
+        tr_bencListAddInt( m, mtimes[i] );
+    }
 
     /* add the bitfield */
     bitfield = tr_cpBlockBitfield( tor->completion );
@@ -292,16 +292,20 @@ loadProgress( tr_benc * dict, tr_torrent * tor )
             && ( m->val.l.count == n ) )
         {
             int i;
-            for( i=0; i<m->val.l.count; ++i ) 
+            for( i=0; i<n; ++i )
             {
-                int64_t x;
-                const time_t t = tr_bencGetInt( &m->val.l.vals[i], &x )
-                                 ? x : verifyNeeded;
-                if( ( t != verifyNeeded ) && ( t == curMTimes[i] ) )
-                    tr_torrentSetFileChecked( tor, i, TRUE );
-                else {
+                int64_t tmp;
+                if( !tr_bencGetInt( &m->val.l.vals[i], &tmp ) ) {
+                    tr_tordbg( tor, "File #%d needs to be verified - couldn't find benc entry", i );
                     tr_torrentSetFileChecked( tor, i, FALSE );
-                    tr_tordbg( tor, "File #%d needs to be verified", i );
+                } else {
+                    const time_t t = (time_t) tmp;
+                    if( t == curMTimes[i] )
+                        tr_torrentSetFileChecked( tor, i, TRUE );
+                    else {
+                        tr_tordbg( tor, "File #%d needs to be verified - times %lu and %lu don't match", t, curMTimes[i] );
+                        tr_torrentSetFileChecked( tor, i, FALSE );
+                    }
                 }
             }
         }
index 55af43848fe6edbe059383a1b4ad4918179ccdb6..e086e78689c6c0f2bd650ea1618e15ed768cceed 100644 (file)
@@ -1428,14 +1428,14 @@ tr_torrentGetMTimes( const tr_torrent * tor, int * setme_n )
 {
     int i;
     const int n = tor->info.fileCount;
-    time_t * m = tr_new( time_t, n );
+    time_t * m = tr_new0( time_t, n );
 
     for( i=0; i<n; ++i ) {
         char fname[MAX_PATH_LENGTH];
         struct stat sb;
         tr_buildPath( fname, sizeof(fname),
                       tor->destination, tor->info.files[i].name, NULL );
-        if ( !stat( fname, &sb ) && S_ISREG( sb.st_mode ) ) {
+        if ( !stat( fname, &sb ) ) {
 #ifdef SYS_DARWIN
             m[i] = sb.st_mtimespec.tv_sec;
 #else