Fix some more off-by-one errors on last piece
See: TRAC-4037 and e2584b04ff
This commit is contained in:
parent
10556943e5
commit
6d5e48f9e2
|
@ -483,7 +483,7 @@ static void saveProgress(tr_variant* dict, tr_torrent* tor)
|
||||||
tr_file const* f = &inf->files[fi];
|
tr_file const* f = &inf->files[fi];
|
||||||
|
|
||||||
/* get the oldest and newest nonzero timestamps for pieces in this file */
|
/* get the oldest and newest nonzero timestamps for pieces in this file */
|
||||||
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece]; p != pend; ++p)
|
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece] + 1; p != pend; ++p)
|
||||||
{
|
{
|
||||||
if (p->timeChecked == 0)
|
if (p->timeChecked == 0)
|
||||||
{
|
{
|
||||||
|
@ -627,7 +627,7 @@ static uint64_t loadProgress(tr_variant* dict, tr_torrent* tor)
|
||||||
{
|
{
|
||||||
tr_file const* f = &inf->files[fi];
|
tr_file const* f = &inf->files[fi];
|
||||||
tr_piece* p = &inf->pieces[f->firstPiece];
|
tr_piece* p = &inf->pieces[f->firstPiece];
|
||||||
tr_piece const* pend = &inf->pieces[f->lastPiece];
|
tr_piece const* pend = &inf->pieces[f->lastPiece] + 1;
|
||||||
time_t const mtime = tr_torrentGetFileMTime(tor, fi);
|
time_t const mtime = tr_torrentGetFileMTime(tor, fi);
|
||||||
time_t const timeChecked = mtime == t ? mtime : 0;
|
time_t const timeChecked = mtime == t ? mtime : 0;
|
||||||
|
|
||||||
|
|
|
@ -3456,7 +3456,7 @@ static void tr_torrentFileCompleted(tr_torrent* tor, tr_file_index_t fileIndex)
|
||||||
|
|
||||||
/* now that the file is complete and closed, we can start watching its
|
/* now that the file is complete and closed, we can start watching its
|
||||||
* mtime timestamp for changes to know if we need to reverify pieces */
|
* mtime timestamp for changes to know if we need to reverify pieces */
|
||||||
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece]; p != pend; ++p)
|
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece] + 1; p != pend; ++p)
|
||||||
{
|
{
|
||||||
p->timeChecked = now;
|
p->timeChecked = now;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue