Egor Orekhov
2016-02-01 12:49:39 UTC
Hi
I have a problem with using resume data.
My lib version is 0.16.19. I have a huge amount of files packed in big compressed pack and implemented custom read/write operations for it. So I want to use them through my own implementation of libtorrent::storage_interface.
After each piece finished I save restore data using same way as described in documentations.
Here is code that write resume data on disk:
if(save_resume_data_alert *srda = alert_cast<save_resume_data_alert>(a))
{
const wg::String tempPath = path + _T(".newresume");
std::ofstream resumeDataStream(tempPath.c_str(), std::ios_base::binary);
resumeDataStream.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(resumeDataStream), *srda->resume_data);
resumeDataStream.close();
RenameFile(tempPath.c_str(), path.c_str());
}
and here is some code for reading operaions
std::ifstream resumeDataStream(resumeDataFileName.c_str(), std::ios_base::binary);
const bool haveResumeData = resumeDataStream.good();
if(haveResumeData)
{
resumeDataStream.unsetf(std::ios_base::skipws);
ts.resume_data = new std::vector<char>;
ts.resume_data->insert(
ts.resume_data->begin(),
std::istreambuf_iterator<char>(resumeDataStream),
std::istreambuf_iterator<char>());
}
//ts is add_torrent_params object which then goes to session::add_torrent
If resume data exist I have bad sequence for calls of libtorrent::storage_interface::write function. As I understand this function should be called for each block of piece sequentially. But when resume data exist write calls alternate for different pieces. If there is no resume data all of libtorrent::storage_interface::write calls performs as expected.
In my implementation of storage interface "write_resume_data" is just empty function that always returns true.
Thanks in forward!
[wargaming.net]
EgzO3mXGcK
This e-mail may contain CONFIDENTIAL AND PROPRIETARY INFORMATION and/or PRIVILEGED AND CONFIDENTIAL COMMUNICATION intended solely for the recipient and, therefore, may not be retransmitted to any party outside of the recipient's organization without the prior written consent of the sender. If you have received this e-mail in error please notify the sender immediately by telephone or reply e-mail and destroy the original message without making a copy. Wargaming.net accepts no liability for any losses or damages resulting from infected e-mail transmissions and viruses in e-mail attachment. kgzO3mXGcg
I have a problem with using resume data.
My lib version is 0.16.19. I have a huge amount of files packed in big compressed pack and implemented custom read/write operations for it. So I want to use them through my own implementation of libtorrent::storage_interface.
After each piece finished I save restore data using same way as described in documentations.
Here is code that write resume data on disk:
if(save_resume_data_alert *srda = alert_cast<save_resume_data_alert>(a))
{
const wg::String tempPath = path + _T(".newresume");
std::ofstream resumeDataStream(tempPath.c_str(), std::ios_base::binary);
resumeDataStream.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(resumeDataStream), *srda->resume_data);
resumeDataStream.close();
RenameFile(tempPath.c_str(), path.c_str());
}
and here is some code for reading operaions
std::ifstream resumeDataStream(resumeDataFileName.c_str(), std::ios_base::binary);
const bool haveResumeData = resumeDataStream.good();
if(haveResumeData)
{
resumeDataStream.unsetf(std::ios_base::skipws);
ts.resume_data = new std::vector<char>;
ts.resume_data->insert(
ts.resume_data->begin(),
std::istreambuf_iterator<char>(resumeDataStream),
std::istreambuf_iterator<char>());
}
//ts is add_torrent_params object which then goes to session::add_torrent
If resume data exist I have bad sequence for calls of libtorrent::storage_interface::write function. As I understand this function should be called for each block of piece sequentially. But when resume data exist write calls alternate for different pieces. If there is no resume data all of libtorrent::storage_interface::write calls performs as expected.
In my implementation of storage interface "write_resume_data" is just empty function that always returns true.
Thanks in forward!
[wargaming.net]
EgzO3mXGcK
This e-mail may contain CONFIDENTIAL AND PROPRIETARY INFORMATION and/or PRIVILEGED AND CONFIDENTIAL COMMUNICATION intended solely for the recipient and, therefore, may not be retransmitted to any party outside of the recipient's organization without the prior written consent of the sender. If you have received this e-mail in error please notify the sender immediately by telephone or reply e-mail and destroy the original message without making a copy. Wargaming.net accepts no liability for any losses or damages resulting from infected e-mail transmissions and viruses in e-mail attachment. kgzO3mXGcg