fixed bug in session::delete_files option to remove_torrent
This commit is contained in:
parent
e489902ffa
commit
0c28a3e3ca
|
@ -85,6 +85,8 @@
|
|||
incoming connection
|
||||
* added more detailed instrumentation of the disk I/O thread
|
||||
|
||||
* fixed bug in session::delete_files option to remove_torrent
|
||||
|
||||
0.15.6 release
|
||||
|
||||
* fixed crash in udp trackers when using SOCKS5 proxy
|
||||
|
|
|
@ -1377,6 +1377,32 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (c == 'q') break;
|
||||
|
||||
if (c == 'D')
|
||||
{
|
||||
torrent_handle h = get_active_torrent(handles).handle;
|
||||
if (h.is_valid())
|
||||
{
|
||||
printf("\n\nARE YOU SURE YOU WANT TO DELETE THE FILES FOR '%s'. THIS OPERATION CANNOT BE UNDONE. (y/N)"
|
||||
, h.name().c_str());
|
||||
char response = 'n';
|
||||
scanf("%c", &response);
|
||||
if (response == 'y')
|
||||
{
|
||||
// also delete the .torrent file from the torrent directory
|
||||
handles_t::iterator i = std::find_if(files.begin(), files.end()
|
||||
, boost::bind(&handles_t::value_type::second, _1) == h);
|
||||
if (i != files.end())
|
||||
{
|
||||
files.erase(i);
|
||||
error_code ec;
|
||||
remove(combine_path(monitor_dir, i->first), ec);
|
||||
if (ec) printf("failed to delete .torrent file: %s\n", ec.message().c_str());
|
||||
}
|
||||
ses.remove_torrent(h, session::delete_files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c == 'j' && !handles.empty())
|
||||
{
|
||||
get_active_torrent(handles).handle.force_recheck();
|
||||
|
|
|
@ -2377,6 +2377,7 @@ namespace libtorrent
|
|||
mutex::scoped_lock l(m_piece_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
// delete all write cache entries for this storage
|
||||
cache_piece_index_t& idx = m_pieces.get<0>();
|
||||
cache_piece_index_t::iterator start = idx.lower_bound(std::pair<void*, int>(j.storage.get(), 0));
|
||||
cache_piece_index_t::iterator end = idx.upper_bound(std::pair<void*, int>(j.storage.get(), INT_MAX));
|
||||
|
@ -2384,17 +2385,21 @@ namespace libtorrent
|
|||
// build a vector of all the buffers we need to free
|
||||
// and free them all in one go
|
||||
std::vector<char*> buffers;
|
||||
torrent_info const& ti = *j.storage->info();
|
||||
for (cache_piece_index_t::iterator i = start; i != end; ++i)
|
||||
{
|
||||
torrent_info const& ti = *i->storage->info();
|
||||
int blocks_in_piece = (ti.piece_size(i->piece) + m_block_size - 1) / m_block_size;
|
||||
cached_piece_entry& e = const_cast<cached_piece_entry&>(*i);
|
||||
for (int j = 0; j < blocks_in_piece; ++j)
|
||||
{
|
||||
if (i->blocks[j].buf == 0) continue;
|
||||
buffers.push_back(i->blocks[j].buf);
|
||||
i->blocks[j].buf = 0;
|
||||
--m_cache_stats.cache_size;
|
||||
TORRENT_ASSERT(e.num_blocks > 0);
|
||||
--e.num_blocks;
|
||||
}
|
||||
TORRENT_ASSERT(i->num_blocks == 0);
|
||||
}
|
||||
idx.erase(start, end);
|
||||
l.unlock();
|
||||
|
|
Loading…
Reference in New Issue