storage fixes

This commit is contained in:
Arvid Norberg
2008-04-12 22:08:07 +00:00
parent dbfd400536
commit d4cfa126aa
11 changed files with 199 additions and 110 deletions

View File

@@ -331,11 +331,15 @@ namespace libtorrent
struct TORRENT_EXPORT file_error_alert: torrent_alert
{
file_error_alert(
const torrent_handle& h
std::string const& f
, const torrent_handle& h
, const std::string& msg)
: torrent_alert(h, alert::fatal, msg)
, file(f)
{}
std::string file;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new file_error_alert(*this)); }
};

View File

@@ -39,20 +39,20 @@ namespace libtorrent
{
namespace aux { class session_impl; }
class disk_io_thread;
struct TORRENT_EXPORT disk_buffer_holder
{
disk_buffer_holder(aux::session_impl& ses, char* buf)
: m_ses(ses), m_buf(buf) {}
disk_buffer_holder(aux::session_impl& ses, char* buf);
disk_buffer_holder(disk_io_thread& iothread, char* buf);
~disk_buffer_holder();
char* release();
char* buffer() const { return m_buf; }
private:
aux::session_impl& m_ses;
disk_io_thread& m_iothread;
char* m_buf;
};
}
#endif

View File

@@ -94,6 +94,10 @@ namespace libtorrent
// to the error message
std::string str;
// on error, this is set to the path of the
// file the disk operation failed on
std::string error_file;
// priority decides whether or not this
// job will skip entries in the queue or
// not. It always skips in front of entries

View File

@@ -161,9 +161,18 @@ namespace libtorrent
// non-zero return value indicates an error
virtual bool delete_files() = 0;
virtual std::string const& error() const = 0;
virtual std::string const& error_file() const = 0;
virtual void clear_error() = 0;
void set_error(std::string const& file, std::string const& msg) const
{
m_error_file = file;
m_error = msg;
}
std::string const& error() const { return m_error; }
std::string const& error_file() const { return m_error_file; }
void clear_error() { m_error.clear(); m_error_file.clear(); }
mutable std::string m_error;
mutable std::string m_error_file;
virtual ~storage_interface() {}
};
@@ -254,6 +263,7 @@ namespace libtorrent
void mark_failed(int index);
std::string const& error() const { return m_storage->error(); }
std::string const& error_file() const { return m_storage->error_file(); }
void clear_error() { m_storage->clear_error(); }
int slot_for(int piece) const;

View File

@@ -467,12 +467,12 @@ namespace libtorrent
// completed() is called immediately after it.
void finished();
void async_verify_piece(int piece_index, boost::function<void(bool)> const&);
void async_verify_piece(int piece_index, boost::function<void(int)> const&);
// this is called from the peer_connection
// each time a piece has failed the hash
// test
void piece_finished(int index, bool passed_hash_check);
void piece_finished(int index, int passed_hash_check);
void piece_failed(int index);
void received_redundant_data(int num_bytes)
{ TORRENT_ASSERT(num_bytes > 0); m_total_redundant_bytes += num_bytes; }
@@ -564,7 +564,7 @@ namespace libtorrent
void on_storage_moved(int ret, disk_io_job const& j);
void on_piece_verified(int ret, disk_io_job const& j
, boost::function<void(bool)> f);
, boost::function<void(int)> f);
void try_next_tracker();
int prioritize_tracker(int tracker_index);