forked from premiere/premiere-libtorrent
improve error handling of failing to change file priority
This commit is contained in:
parent
396c5dd3af
commit
c55bc7dd42
|
@ -1,4 +1,6 @@
|
|||
|
||||
* improve error handling of failing to change file priority
|
||||
The API for custom storage implementations was altered
|
||||
* set the hidden attribute when creating the part file
|
||||
* fix tracker announces reporting more data downloaded than the size of the torrent
|
||||
* fix recent regression with force_proxy setting
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace libtorrent
|
|||
// change the priorities of files. This is a fenced job and is
|
||||
// guaranteed to be the only running function on this storage
|
||||
// when called
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t> const& prio
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t>& prio
|
||||
, storage_error& ec) = 0;
|
||||
|
||||
// This function should move all the files belonging to the storage to
|
||||
|
@ -427,7 +427,7 @@ namespace libtorrent
|
|||
void finalize_file(int file, storage_error& ec) TORRENT_OVERRIDE;
|
||||
#endif
|
||||
virtual bool has_any_file(storage_error& ec) TORRENT_OVERRIDE;
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t> const& prio
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t>& prio
|
||||
, storage_error& ec) TORRENT_OVERRIDE;
|
||||
virtual void rename_file(int index, std::string const& new_filename
|
||||
, storage_error& ec) TORRENT_OVERRIDE;
|
||||
|
@ -524,7 +524,7 @@ namespace libtorrent
|
|||
{
|
||||
public:
|
||||
virtual bool has_any_file(storage_error&) TORRENT_OVERRIDE { return false; }
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t> const&
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t>&
|
||||
, storage_error&) TORRENT_OVERRIDE {}
|
||||
virtual void rename_file(int, std::string const&, storage_error&) TORRENT_OVERRIDE {}
|
||||
virtual void release_files(storage_error&) TORRENT_OVERRIDE {}
|
||||
|
@ -555,7 +555,7 @@ namespace libtorrent
|
|||
, int piece, int offset, int flags, storage_error& ec) TORRENT_OVERRIDE;
|
||||
|
||||
virtual bool has_any_file(storage_error&) TORRENT_OVERRIDE { return false; }
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t> const& /* prio */
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t>& /* prio */
|
||||
, storage_error&) TORRENT_OVERRIDE {}
|
||||
virtual int move_storage(std::string const& /* save_path */
|
||||
, int /* flags */, storage_error&) TORRENT_OVERRIDE { return 0; }
|
||||
|
|
|
@ -544,7 +544,7 @@ namespace libtorrent
|
|||
void set_file_priority(int index, int priority);
|
||||
int file_priority(int index) const;
|
||||
|
||||
void on_file_priority();
|
||||
void on_file_priority(disk_io_job const* j);
|
||||
void prioritize_files(std::vector<int> const& files);
|
||||
void file_priorities(std::vector<int>*) const;
|
||||
|
||||
|
|
|
@ -2991,8 +2991,7 @@ namespace libtorrent
|
|||
|
||||
int disk_io_thread::do_file_priority(disk_io_job* j, jobqueue_t& /* completed_jobs */ )
|
||||
{
|
||||
boost::scoped_ptr<std::vector<boost::uint8_t> > p(j->buffer.priorities);
|
||||
j->storage->get_storage_impl()->set_file_priority(*p, j->error);
|
||||
j->storage->get_storage_impl()->set_file_priority(*j->buffer.priorities, j->error);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ namespace libtorrent
|
|||
, m_files.num_pieces(), m_files.piece_length()));
|
||||
}
|
||||
|
||||
void default_storage::set_file_priority(std::vector<boost::uint8_t> const& prio, storage_error& ec)
|
||||
void default_storage::set_file_priority(std::vector<boost::uint8_t>& prio, storage_error& ec)
|
||||
{
|
||||
// extend our file priorities in case it's truncated
|
||||
// the default assumed priority is 4 (the default)
|
||||
|
@ -459,6 +459,7 @@ namespace libtorrent
|
|||
{
|
||||
ec.file = i;
|
||||
ec.operation = storage_error::open;
|
||||
prio = m_file_priority;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -469,6 +470,7 @@ namespace libtorrent
|
|||
{
|
||||
ec.file = i;
|
||||
ec.operation = storage_error::partfile_write;
|
||||
prio = m_file_priority;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +487,13 @@ namespace libtorrent
|
|||
file_handle f = open_file(i, file::read_only, ec);
|
||||
if (ec.ec != boost::system::errc::no_such_file_or_directory)
|
||||
{
|
||||
if (ec) return;
|
||||
if (ec)
|
||||
{
|
||||
ec.file = i;
|
||||
ec.operation = storage_error::open;
|
||||
prio = m_file_priority;
|
||||
return;
|
||||
}
|
||||
|
||||
need_partfile();
|
||||
|
||||
|
@ -494,6 +502,7 @@ namespace libtorrent
|
|||
{
|
||||
ec.file = i;
|
||||
ec.operation = storage_error::partfile_read;
|
||||
prio = m_file_priority;
|
||||
return;
|
||||
}
|
||||
// remove the file
|
||||
|
@ -503,6 +512,8 @@ namespace libtorrent
|
|||
{
|
||||
ec.file = i;
|
||||
ec.operation = storage_error::remove;
|
||||
prio = m_file_priority;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -5658,9 +5658,22 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
void torrent::on_file_priority()
|
||||
void torrent::on_file_priority(disk_io_job const* j)
|
||||
{
|
||||
dec_refcount("file_priority");
|
||||
boost::scoped_ptr<std::vector<boost::uint8_t> > p(j->buffer.priorities);
|
||||
if (m_file_priority == *p) return;
|
||||
|
||||
// in this case, some file priorities failed to get set
|
||||
m_file_priority = *p;
|
||||
update_piece_priorities();
|
||||
|
||||
if (alerts().should_post<file_error_alert>())
|
||||
alerts().emplace_alert<file_error_alert>(j->error.ec
|
||||
, resolve_filename(j->error.file), j->error.operation_str(), get_handle());
|
||||
|
||||
set_error(j->error.ec, j->error.file);
|
||||
pause();
|
||||
}
|
||||
|
||||
void torrent::prioritize_files(std::vector<int> const& files)
|
||||
|
@ -5699,7 +5712,7 @@ namespace {
|
|||
{
|
||||
inc_refcount("file_priority");
|
||||
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
||||
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this()));
|
||||
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this(), _1));
|
||||
}
|
||||
|
||||
update_piece_priorities();
|
||||
|
@ -5738,7 +5751,7 @@ namespace {
|
|||
{
|
||||
inc_refcount("file_priority");
|
||||
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
||||
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this()));
|
||||
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this(), _1));
|
||||
}
|
||||
update_piece_priorities();
|
||||
}
|
||||
|
@ -7145,7 +7158,7 @@ namespace {
|
|||
{
|
||||
inc_refcount("file_priority");
|
||||
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
||||
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this()));
|
||||
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this(), _1));
|
||||
}
|
||||
|
||||
update_piece_priorities();
|
||||
|
|
|
@ -61,7 +61,7 @@ struct test_storage_impl : storage_interface
|
|||
}
|
||||
|
||||
virtual bool has_any_file(storage_error& ec) { return false; }
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t> const& prio
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t>& prio
|
||||
, storage_error& ec) {}
|
||||
virtual int move_storage(std::string const& save_path, int flags
|
||||
, storage_error& ec) { return 0; }
|
||||
|
|
|
@ -78,8 +78,8 @@ struct test_storage : default_storage
|
|||
, m_limit(16 * 1024 * 2)
|
||||
{}
|
||||
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t> const& p
|
||||
, storage_error& ec) {}
|
||||
virtual void set_file_priority(std::vector<boost::uint8_t>& p
|
||||
, storage_error& ec) TORRENT_OVERRIDE {}
|
||||
|
||||
void set_limit(int lim)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ struct test_storage : default_storage
|
|||
, int piece_index
|
||||
, int offset
|
||||
, int flags
|
||||
, storage_error& se)
|
||||
, storage_error& se) TORRENT_OVERRIDE
|
||||
{
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
if (m_written >= m_limit)
|
||||
|
|
Loading…
Reference in New Issue