more lt storage fixes
This commit is contained in:
parent
8093185a4b
commit
b435822191
|
@ -248,10 +248,10 @@ namespace libtorrent
|
||||||
void set_size(size_type s)
|
void set_size(size_type s)
|
||||||
{
|
{
|
||||||
size_type pos = tell();
|
size_type pos = tell();
|
||||||
seek(s);
|
seek(s - 1);
|
||||||
char dummy = 0;
|
char dummy = 0;
|
||||||
read(&dummy, 1);
|
read(&dummy, 1);
|
||||||
seek(s);
|
seek(s - 1);
|
||||||
write(&dummy, 1);
|
write(&dummy, 1);
|
||||||
seek(pos);
|
seek(pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,6 +412,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void storage::initialize(bool allocate_files)
|
void storage::initialize(bool allocate_files)
|
||||||
{
|
{
|
||||||
|
std::cerr << "storage initialize" << std::endl;
|
||||||
// first, create all missing directories
|
// first, create all missing directories
|
||||||
path last_path;
|
path last_path;
|
||||||
for (torrent_info::file_iterator file_iter = m_info.begin_files(),
|
for (torrent_info::file_iterator file_iter = m_info.begin_files(),
|
||||||
|
@ -436,6 +437,7 @@ namespace libtorrent
|
||||||
// the directory exits.
|
// the directory exits.
|
||||||
if (file_iter->size == 0)
|
if (file_iter->size == 0)
|
||||||
{
|
{
|
||||||
|
std::cerr << "creating empty file: " << file_iter->path.string() << std::endl;
|
||||||
file(m_save_path / file_iter->path, file::out);
|
file(m_save_path / file_iter->path, file::out);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1612,20 +1614,17 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_unallocated_slots.push_back(i);
|
m_unallocated_slots.push_back(i);
|
||||||
}
|
}
|
||||||
if (m_unallocated_slots.empty())
|
if (m_compact_mode || m_unallocated_slots.empty())
|
||||||
{
|
|
||||||
m_state = state_finished;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (m_compact_mode)
|
|
||||||
{
|
{
|
||||||
m_state = state_create_files;
|
m_state = state_create_files;
|
||||||
|
std::cerr << "storage: -> create_files" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_current_slot = 0;
|
m_current_slot = 0;
|
||||||
m_state = state_full_check;
|
m_state = state_full_check;
|
||||||
|
std::cerr << "storage: -> full_check" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1669,7 +1668,7 @@ namespace libtorrent
|
||||||
if (m_compact_mode || m_unallocated_slots.empty())
|
if (m_compact_mode || m_unallocated_slots.empty())
|
||||||
{
|
{
|
||||||
m_state = state_create_files;
|
m_state = state_create_files;
|
||||||
return std::make_pair(true, 1.f);
|
return std::make_pair(false, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (int(m_unallocated_slots.size()) == m_info.num_pieces()
|
if (int(m_unallocated_slots.size()) == m_info.num_pieces()
|
||||||
|
@ -1709,7 +1708,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_storage->initialize(!m_fill_mode && !m_compact_mode);
|
m_storage->initialize(!m_fill_mode && !m_compact_mode);
|
||||||
|
|
||||||
if (!m_unallocated_slots.empty())
|
if (!m_unallocated_slots.empty() && !m_compact_mode)
|
||||||
{
|
{
|
||||||
assert(!m_fill_mode);
|
assert(!m_fill_mode);
|
||||||
assert(!m_compact_mode);
|
assert(!m_compact_mode);
|
||||||
|
|
Loading…
Reference in New Issue