1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

add more debugging messages for loading progress from the bencoded resume file

This commit is contained in:
Charles Kerr 2008-04-14 20:30:43 +00:00
parent 7f89ee3db2
commit 35502f0559
2 changed files with 19 additions and 15 deletions

View 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] ) )
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 );
} 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 );
tr_tordbg( tor, "File #%d needs to be verified", i );
}
}
}
}

View 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