****
***/
-static const time_t verifyNeeded = ~(time_t)0;
-
static void
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 );
&& ( 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 );
+ }
}
}
}
{
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