fixed another sparse files related bug in storage
This commit is contained in:
parent
f942308ccb
commit
c39462c125
|
@ -628,6 +628,9 @@ namespace libtorrent
|
|||
++file_iter;
|
||||
}
|
||||
|
||||
int buf_pos = 0;
|
||||
try
|
||||
{
|
||||
boost::shared_ptr<file> in(m_files.open_file(
|
||||
this, m_save_path / file_iter->path, file::in));
|
||||
|
||||
|
@ -656,7 +659,6 @@ namespace libtorrent
|
|||
assert(left_to_read >= 0);
|
||||
|
||||
size_type result = left_to_read;
|
||||
int buf_pos = 0;
|
||||
|
||||
#ifndef NDEBUG
|
||||
int counter = 0;
|
||||
|
@ -682,16 +684,10 @@ namespace libtorrent
|
|||
|
||||
if (read_bytes != actual_read)
|
||||
{
|
||||
if (fill_zero && actual_read < read_bytes)
|
||||
{
|
||||
std::memset(buf + buf_pos + actual_read, 0, read_bytes - actual_read);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (actual_read > 0) buf_pos += actual_read;
|
||||
// the file was not big enough
|
||||
throw file_error("slot has no storage");
|
||||
}
|
||||
}
|
||||
|
||||
left_to_read -= read_bytes;
|
||||
buf_pos += read_bytes;
|
||||
|
@ -715,9 +711,18 @@ namespace libtorrent
|
|||
in->seek(0);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
if (fill_zero)
|
||||
{
|
||||
std::memset(buf + buf_pos, 0, size - buf_pos);
|
||||
return size;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// throws file_error if it fails to write
|
||||
void storage::write(
|
||||
|
|
Loading…
Reference in New Issue