diff --git a/libtorrent/src/file.cpp b/libtorrent/src/file.cpp index f641848c7..a1352ae03 100755 --- a/libtorrent/src/file.cpp +++ b/libtorrent/src/file.cpp @@ -248,10 +248,10 @@ namespace libtorrent void set_size(size_type s) { size_type pos = tell(); - seek(s); + seek(s - 1); char dummy = 0; read(&dummy, 1); - seek(s); + seek(s - 1); write(&dummy, 1); seek(pos); } diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index dc0371d73..9a8165af2 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -412,6 +412,7 @@ namespace libtorrent void storage::initialize(bool allocate_files) { + std::cerr << "storage initialize" << std::endl; // first, create all missing directories path last_path; for (torrent_info::file_iterator file_iter = m_info.begin_files(), @@ -436,6 +437,7 @@ namespace libtorrent // the directory exits. 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); continue; } @@ -1612,20 +1614,17 @@ namespace libtorrent { m_unallocated_slots.push_back(i); } - if (m_unallocated_slots.empty()) - { - m_state = state_finished; - return true; - } - if (m_compact_mode) + if (m_compact_mode || m_unallocated_slots.empty()) { m_state = state_create_files; + std::cerr << "storage: -> create_files" << std::endl; return false; } } m_current_slot = 0; m_state = state_full_check; + std::cerr << "storage: -> full_check" << std::endl; return false; } @@ -1669,7 +1668,7 @@ namespace libtorrent if (m_compact_mode || m_unallocated_slots.empty()) { 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() @@ -1709,7 +1708,7 @@ namespace libtorrent { 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_compact_mode);