fixed rename_file() bug where the new name would not be saved in the resume data in some cases
This commit is contained in:
parent
93e1c70263
commit
cc3e6621ed
|
@ -67,6 +67,8 @@ release 0.14.5
|
||||||
* fixed memory leak in disk io thread when not using the cache
|
* fixed memory leak in disk io thread when not using the cache
|
||||||
* fixed bug in connect candidate counter
|
* fixed bug in connect candidate counter
|
||||||
* allow 0 upload slots
|
* allow 0 upload slots
|
||||||
|
* fixed bug in rename_file(). The new name would not always be saved in
|
||||||
|
the resume data
|
||||||
|
|
||||||
release 0.14.4
|
release 0.14.4
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@ add_torrent()
|
||||||
::
|
::
|
||||||
|
|
||||||
typedef storage_interface* (&storage_constructor_type)(
|
typedef storage_interface* (&storage_constructor_type)(
|
||||||
file_storage const&, fs::path const&, file_pool&);
|
file_storage const&, file_storage const*, fs::path const&, file_pool&);
|
||||||
|
|
||||||
struct add_torrent_params
|
struct add_torrent_params
|
||||||
{
|
{
|
||||||
|
|
|
@ -230,7 +230,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
file_pool fp;
|
file_pool fp;
|
||||||
boost::scoped_ptr<storage_interface> st(
|
boost::scoped_ptr<storage_interface> st(
|
||||||
default_storage_constructor(const_cast<file_storage&>(t.files()), p, fp));
|
default_storage_constructor(const_cast<file_storage&>(t.files()), 0, p, fp));
|
||||||
|
|
||||||
// calculate the hash for all pieces
|
// calculate the hash for all pieces
|
||||||
int num = t.num_pieces();
|
int num = t.num_pieces();
|
||||||
|
@ -304,7 +304,7 @@ namespace libtorrent
|
||||||
std::string utf8;
|
std::string utf8;
|
||||||
wchar_utf8(p.string(), utf8);
|
wchar_utf8(p.string(), utf8);
|
||||||
boost::scoped_ptr<storage_interface> st(
|
boost::scoped_ptr<storage_interface> st(
|
||||||
default_storage_constructor(const_cast<file_storage&>(t.files()), utf8, fp));
|
default_storage_constructor(const_cast<file_storage&>(t.files()), 0, utf8, fp));
|
||||||
|
|
||||||
// calculate the hash for all pieces
|
// calculate the hash for all pieces
|
||||||
int num = t.num_pieces();
|
int num = t.num_pieces();
|
||||||
|
|
|
@ -190,10 +190,10 @@ namespace libtorrent
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef storage_interface* (*storage_constructor_type)(
|
typedef storage_interface* (*storage_constructor_type)(
|
||||||
file_storage const&, fs::path const&, file_pool&);
|
file_storage const&, file_storage const*, fs::path const&, file_pool&);
|
||||||
|
|
||||||
TORRENT_EXPORT storage_interface* default_storage_constructor(
|
TORRENT_EXPORT storage_interface* default_storage_constructor(
|
||||||
file_storage const&, fs::path const&, file_pool&);
|
file_storage const&, file_storage const* orig, fs::path const&, file_pool&);
|
||||||
|
|
||||||
struct disk_io_thread;
|
struct disk_io_thread;
|
||||||
|
|
||||||
|
|
|
@ -398,12 +398,14 @@ namespace libtorrent
|
||||||
class storage : public storage_interface, boost::noncopyable
|
class storage : public storage_interface, boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
storage(file_storage const& fs, fs::path const& path, file_pool& fp)
|
storage(file_storage const& fs, file_storage const* orig, fs::path const& path, file_pool& fp)
|
||||||
: m_files(fs)
|
: m_files(fs)
|
||||||
, m_pool(fp)
|
, m_pool(fp)
|
||||||
, m_page_size(4096)
|
, m_page_size(4096)
|
||||||
, m_allocate_files(false)
|
, m_allocate_files(false)
|
||||||
{
|
{
|
||||||
|
if (orig) m_mapped_files.reset(new file_storage(*orig));
|
||||||
|
|
||||||
TORRENT_ASSERT(m_files.begin() != m_files.end());
|
TORRENT_ASSERT(m_files.begin() != m_files.end());
|
||||||
m_save_path = fs::complete(path);
|
m_save_path = fs::complete(path);
|
||||||
TORRENT_ASSERT(m_save_path.is_complete());
|
TORRENT_ASSERT(m_save_path.is_complete());
|
||||||
|
@ -890,6 +892,18 @@ namespace libtorrent
|
||||||
|
|
||||||
bool storage::verify_resume_data(lazy_entry const& rd, std::string& error)
|
bool storage::verify_resume_data(lazy_entry const& rd, std::string& error)
|
||||||
{
|
{
|
||||||
|
lazy_entry const* mapped_files = rd.dict_find_list("mapped_files");
|
||||||
|
if (mapped_files && mapped_files->list_size() == m_files.num_files())
|
||||||
|
{
|
||||||
|
m_mapped_files.reset(new file_storage(m_files));
|
||||||
|
for (int i = 0; i < m_files.num_files(); ++i)
|
||||||
|
{
|
||||||
|
std::string new_filename = mapped_files->list_string_value_at(i);
|
||||||
|
if (new_filename.empty()) continue;
|
||||||
|
m_mapped_files->rename_file(i, new_filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lazy_entry const* file_priority = rd.dict_find_list("file_priority");
|
lazy_entry const* file_priority = rd.dict_find_list("file_priority");
|
||||||
if (file_priority && file_priority->list_size()
|
if (file_priority && file_priority->list_size()
|
||||||
== files().num_files())
|
== files().num_files())
|
||||||
|
@ -1471,9 +1485,9 @@ ret:
|
||||||
}
|
}
|
||||||
|
|
||||||
storage_interface* default_storage_constructor(file_storage const& fs
|
storage_interface* default_storage_constructor(file_storage const& fs
|
||||||
, fs::path const& path, file_pool& fp)
|
, file_storage const* orig, fs::path const& path, file_pool& fp)
|
||||||
{
|
{
|
||||||
return new storage(fs, path, fp);
|
return new storage(fs, orig, path, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- piece_manager -----------------------------------------------------
|
// -- piece_manager -----------------------------------------------------
|
||||||
|
@ -1488,7 +1502,8 @@ ret:
|
||||||
, storage_mode_t sm)
|
, storage_mode_t sm)
|
||||||
: m_info(info)
|
: m_info(info)
|
||||||
, m_files(m_info->files())
|
, m_files(m_info->files())
|
||||||
, m_storage(sc(m_files, save_path, fp))
|
, m_storage(sc(m_info->files(), &m_info->files() != &m_info->orig_files()
|
||||||
|
? &m_info->orig_files() : 0, save_path, fp))
|
||||||
, m_storage_mode(sm)
|
, m_storage_mode(sm)
|
||||||
, m_save_path(complete(save_path))
|
, m_save_path(complete(save_path))
|
||||||
, m_state(state_none)
|
, m_state(state_none)
|
||||||
|
|
|
@ -3257,7 +3257,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::string new_filename = mapped_files->list_string_value_at(i);
|
std::string new_filename = mapped_files->list_string_value_at(i);
|
||||||
if (new_filename.empty()) continue;
|
if (new_filename.empty()) continue;
|
||||||
rename_file(i, new_filename);
|
m_torrent_file->rename_file(i, new_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
||||||
file_pool fp;
|
file_pool fp;
|
||||||
disk_buffer_pool dp(16 * 1024);
|
disk_buffer_pool dp(16 * 1024);
|
||||||
boost::scoped_ptr<storage_interface> s(
|
boost::scoped_ptr<storage_interface> s(
|
||||||
default_storage_constructor(fs, test_path, fp));
|
default_storage_constructor(fs, 0, test_path, fp));
|
||||||
s->m_settings = &set;
|
s->m_settings = &set;
|
||||||
s->m_disk_pool = &dp;
|
s->m_disk_pool = &dp;
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void test_remove(path const& test_path, bool unbuffered)
|
||||||
file_pool fp;
|
file_pool fp;
|
||||||
disk_buffer_pool dp(16 * 1024);
|
disk_buffer_pool dp(16 * 1024);
|
||||||
boost::scoped_ptr<storage_interface> s(
|
boost::scoped_ptr<storage_interface> s(
|
||||||
default_storage_constructor(fs, test_path, fp));
|
default_storage_constructor(fs, 0, test_path, fp));
|
||||||
s->m_settings = &set;
|
s->m_settings = &set;
|
||||||
s->m_disk_pool = &dp;
|
s->m_disk_pool = &dp;
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ void print_alert(alert const& a)
|
||||||
struct test_storage : storage_interface
|
struct test_storage : storage_interface
|
||||||
{
|
{
|
||||||
test_storage(file_storage const& fs, fs::path const& p, file_pool& fp)
|
test_storage(file_storage const& fs, fs::path const& p, file_pool& fp)
|
||||||
: m_lower_layer(default_storage_constructor(fs, p, fp))
|
: m_lower_layer(default_storage_constructor(fs, 0, p, fp))
|
||||||
, m_written(0)
|
, m_written(0)
|
||||||
, m_limit(16 * 1024 * 2)
|
, m_limit(16 * 1024 * 2)
|
||||||
{}
|
{}
|
||||||
|
@ -204,7 +204,7 @@ struct test_storage : storage_interface
|
||||||
};
|
};
|
||||||
|
|
||||||
storage_interface* test_storage_constructor(file_storage const& fs
|
storage_interface* test_storage_constructor(file_storage const& fs
|
||||||
, fs::path const& path, file_pool& fp)
|
, file_storage const*, fs::path const& path, file_pool& fp)
|
||||||
{
|
{
|
||||||
return new test_storage(fs, path, fp);
|
return new test_storage(fs, path, fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue