merge fix for deleting files from libtorrent_aio

This commit is contained in:
Arvid Norberg 2013-08-22 05:27:45 +00:00
parent f72f77aeb2
commit 6a47271667
3 changed files with 13 additions and 0 deletions

View File

@ -127,6 +127,8 @@ namespace libtorrent
static sha1_hash empty; static sha1_hash empty;
return m_torrent_file ? m_torrent_file->info_hash() : empty; return m_torrent_file ? m_torrent_file->info_hash() : empty;
} }
bool is_deleted() const { return m_deleted; }
// starts the announce timer // starts the announce timer
void start(); void start();
@ -1388,6 +1390,11 @@ namespace libtorrent
// accidentally start seeding it without any authentication. // accidentally start seeding it without any authentication.
bool m_ssl_torrent:1; bool m_ssl_torrent:1;
// this is set to true if we're trying to delete the
// files belonging to it. When set, don't write any
// more blocks to disk!
bool m_deleted:1;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
public: public:
// set to false until we've loaded resume data // set to false until we've loaded resume data

View File

@ -2472,6 +2472,8 @@ namespace libtorrent
} }
} }
if (t->is_deleted()) return;
int write_queue_size = fs.async_write(p, data, boost::bind(&peer_connection::on_disk_write_complete int write_queue_size = fs.async_write(p, data, boost::bind(&peer_connection::on_disk_write_complete
, self(), _1, _2, p, t)); , self(), _1, _2, p, t));
m_outstanding_writing_bytes += p.length; m_outstanding_writing_bytes += p.length;

View File

@ -428,6 +428,7 @@ namespace libtorrent
, m_is_active_download(false) , m_is_active_download(false)
, m_is_active_finished(false) , m_is_active_finished(false)
, m_ssl_torrent(false) , m_ssl_torrent(false)
, m_deleted(false)
{ {
// if there is resume data already, we don't need to trigger the initial save // if there is resume data already, we don't need to trigger the initial save
// resume data // resume data
@ -1220,6 +1221,8 @@ namespace libtorrent
int piece_size = m_torrent_file->piece_size(piece); int piece_size = m_torrent_file->piece_size(piece);
int blocks_in_piece = (piece_size + block_size() - 1) / block_size(); int blocks_in_piece = (piece_size + block_size() - 1) / block_size();
if (m_deleted) return;
// avoid crash trying to access the picker when there is none // avoid crash trying to access the picker when there is none
if (!has_picker()) return; if (!has_picker()) return;
@ -7029,6 +7032,7 @@ namespace libtorrent
TORRENT_ASSERT(m_storage); TORRENT_ASSERT(m_storage);
m_storage->async_delete_files( m_storage->async_delete_files(
boost::bind(&torrent::on_files_deleted, shared_from_this(), _1, _2)); boost::bind(&torrent::on_files_deleted, shared_from_this(), _1, _2));
m_deleted = true;
return true; return true;
} }
return false; return false;