From f729893016a66a6878c54dbcb799bc95177bd3de Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 18 Jan 2004 10:22:18 +0000 Subject: [PATCH] *** empty log message *** --- src/peer_connection.cpp | 9 +++++++++ src/storage.cpp | 30 ++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 342d2f015..dea77a3e6 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -679,6 +679,8 @@ namespace libtorrent m_torrent->filesystem().write(&m_recv_buffer[9], p.piece, p.start, p.length); + bool was_seed = is_seed(); + picker.mark_as_finished(block_finished, m_socket->sender()); m_torrent->get_policy().block_finished(*this, block_finished); @@ -698,6 +700,13 @@ namespace libtorrent m_torrent->piece_failed(p.piece); } m_torrent->get_policy().piece_finished(p.piece, verified); + + if (!was_seed && is_seed()) + { + assert(verified); + // TODO: post torrent_finished_alert + } + } } diff --git a/src/storage.cpp b/src/storage.cpp index a0290e8d7..ac0728bd6 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -108,9 +108,18 @@ namespace libtorrent i != t.end_files(); ++i) { - file f(p / i->path / i->filename, file::in); - f.seek(0, file::end); - sizes.push_back(f.tell()); + size_type file_size; + try + { + file f(p / i->path / i->filename, file::in); + f.seek(0, file::end); + file_size = f.tell(); + } + catch (file_error&) + { + file_size = 0; + } + sizes.push_back(file_size); } return sizes; } @@ -127,9 +136,18 @@ namespace libtorrent i != t.end_files(); ++i, ++s) { - file f(p / i->path / i->filename, file::in); - f.seek(0, file::end); - if (f.tell() != *s) return false; + size_type file_size; + try + { + file f(p / i->path / i->filename, file::in); + f.seek(0, file::end); + file_size = f.tell(); + } + catch (file_error&) + { + file_size = 0; + } + if (file_size != *s) return false; } return true; }