Changeset 13907
- Timestamp:
- Jan 31, 2013, 5:10:08 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/libtransmission-test.c
r13879 r13907 325 325 #define verify_and_block_until_done(tor) \ 326 326 do { \ 327 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \ 327 328 tr_torrentVerify (tor); \ 328 do { \ 329 tr_wait_msec (10); \ 330 } while (tor->verifyState != TR_VERIFY_NONE); \ 329 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \ 331 330 } while (0) 332 331 … … 347 346 struct stat sb; 348 347 349 path = tr_buildPath (tor->currentDir, file->name, NULL); 348 if (!complete && (i==0)) 349 path = tr_strdup_printf ("%s%c%s.part", tor->currentDir, TR_PATH_DELIMITER, file->name); 350 else 351 path = tr_strdup_printf ("%s%c%s", tor->currentDir, TR_PATH_DELIMITER, file->name); 350 352 dirname = tr_dirname (path); 351 353 tr_mkdirp (dirname, 0700); 352 354 fp = fopen (path, "wb+"); 353 355 for (j=0; j<file->length; ++j) 354 fputc ( '\0', fp);356 fputc (((!complete) && (i==0) && (j<tor->info.pieceSize)) ? '\1' : '\0', fp); 355 357 fclose (fp); 356 358 … … 366 368 367 369 sync (); 368 369 if (!complete) 370 { 371 FILE * fp; 372 char * oldpath = tr_torrentFindFile (tor, 0); 373 char * newpath = tr_strdup_printf ("%s.part", oldpath); 374 375 rename (oldpath, newpath); 376 377 /* invalidate one piece */ 378 fp = fopen (newpath, "rb+"); 379 fputc ('\1', fp); 380 fclose (fp); 381 382 tr_free (newpath); 383 tr_free (oldpath); 384 385 sync (); 386 verify_and_block_until_done (tor); 387 assert (tr_torrentStat(tor)->leftUntilDone == tor->info.pieceSize); 388 } 389 } 370 verify_and_block_until_done (tor); 371 372 if (complete) 373 assert (tr_torrentStat(tor)->leftUntilDone == 0); 374 else 375 assert (tr_torrentStat(tor)->leftUntilDone == tor->info.pieceSize); 376 }
Note: See TracChangeset
for help on using the changeset viewer.