forked from premiere/premiere-libtorrent
fixed storage to generate a proper error when the read operation
This commit is contained in:
parent
d0546e702f
commit
b9d7538ba8
|
@ -476,7 +476,7 @@ namespace libtorrent
|
|||
{
|
||||
l.unlock();
|
||||
file::iovec_t b = { buf.get(), buffer_size };
|
||||
ret += p.storage->read_impl(&b, p.piece, start_block * m_block_size, 1);
|
||||
ret = p.storage->read_impl(&b, p.piece, start_block * m_block_size, 1);
|
||||
l.lock();
|
||||
if (p.storage->error()) { return -1; }
|
||||
++m_cache_stats.reads;
|
||||
|
@ -508,13 +508,14 @@ namespace libtorrent
|
|||
if (iov)
|
||||
{
|
||||
l.unlock();
|
||||
ret += p.storage->read_impl(iov.get(), p.piece, start_block * m_block_size, iov_counter);
|
||||
ret = p.storage->read_impl(iov.get(), p.piece, start_block * m_block_size, iov_counter);
|
||||
l.lock();
|
||||
if (p.storage->error()) { return -1; }
|
||||
++m_cache_stats.reads;
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(ret <= buffer_size);
|
||||
TORRENT_ASSERT(ret == buffer_size || p.storage->error());
|
||||
return (ret != buffer_size) ? -1 : ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1137,10 +1137,20 @@ ret:
|
|||
+ file_offset, tmp_bufs, num_tmp_bufs, ec));
|
||||
file_offset = 0;
|
||||
|
||||
if (read_bytes != actual_read || ec)
|
||||
if (ec)
|
||||
{
|
||||
set_error(m_save_path / file_iter->path, ec);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_bytes != actual_read)
|
||||
{
|
||||
// the file was not big enough
|
||||
if (actual_read > 0) buf_pos += actual_read;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
ec = error_code(ERROR_READ_FAULT, get_system_category());
|
||||
#else
|
||||
ec = error_code(EIO, get_posix_category());
|
||||
#endif
|
||||
set_error(m_save_path / file_iter->path, ec);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1283,10 +1293,20 @@ ret:
|
|||
|
||||
file_offset = 0;
|
||||
|
||||
if (write_bytes != actual_written || ec)
|
||||
if (ec)
|
||||
{
|
||||
set_error(m_save_path / file_iter->path, ec);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write_bytes != actual_written)
|
||||
{
|
||||
// the file was not big enough
|
||||
if (actual_written > 0) buf_pos += actual_written;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
ec = error_code(ERROR_READ_FAULT, get_system_category());
|
||||
#else
|
||||
ec = error_code(EIO, get_posix_category());
|
||||
#endif
|
||||
set_error(m_save_path / file_iter->path, ec);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue