don't create all directories up front when adding torrents

This commit is contained in:
Arvid Norberg 2011-08-01 00:22:54 +00:00
parent 68aa222a58
commit e81dbfb7f8
2 changed files with 17 additions and 11 deletions

View File

@ -1,3 +1,4 @@
* don't create all directories up front when adding torrents
* support DHT scrape
* added support for fadvise/F_RDADVISE for improved disk read performance
* introduced pop_alerts() which pops the entire alert queue in a single call

View File

@ -453,17 +453,6 @@ namespace libtorrent
for (file_storage::iterator file_iter = files().begin(),
end_iter = files().end(); file_iter != end_iter; ++file_iter)
{
std::string file_path = combine_path(m_save_path, files().file_path(*file_iter));
std::string dir = parent_path(file_path);
if (dir != last_path)
{
last_path = dir;
if (!is_directory(last_path, ec))
create_directories(last_path, ec);
}
int file_index = files().file_index(*file_iter);
// ignore files that have priority 0
@ -473,6 +462,8 @@ namespace libtorrent
// ignore pad files
if (file_iter->pad_file) continue;
std::string file_path = combine_path(m_save_path, files().file_path(*file_iter));
file_status s;
stat_file(file_path, &s, ec);
if (ec && ec != boost::system::errc::no_such_file_or_directory
@ -489,7 +480,21 @@ namespace libtorrent
// if the file is empty, just create it either way.
if ((ec && allocate_files) || (!ec && s.file_size > file_iter->size) || file_iter->size == 0)
{
std::string dir = parent_path(file_path);
if (dir != last_path)
{
last_path = dir;
create_directories(last_path, ec);
if (ec)
{
set_error(dir, ec);
break;
}
}
ec.clear();
boost::intrusive_ptr<file> f = open_file(file_iter, file::read_write, ec);
if (ec) set_error(file_path, ec);
else if (f)