storage cleanup and truncating files that are larger than they should be
This commit is contained in:
parent
ef8e2c6d50
commit
d6a8c28d9c
|
@ -505,18 +505,16 @@ namespace libtorrent
|
||||||
|
|
||||||
if (dir != last_path)
|
if (dir != last_path)
|
||||||
{
|
{
|
||||||
|
last_path = dir;
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 103400
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 103400
|
||||||
last_path = dir;
|
|
||||||
if (!exists_win(last_path))
|
if (!exists_win(last_path))
|
||||||
create_directories_win(last_path);
|
create_directories_win(last_path);
|
||||||
#elif TORRENT_USE_WPATH
|
#elif TORRENT_USE_WPATH
|
||||||
last_path = dir;
|
|
||||||
fs::wpath wp = safe_convert(last_path.string());
|
fs::wpath wp = safe_convert(last_path.string());
|
||||||
if (!exists(wp))
|
if (!exists(wp))
|
||||||
create_directories(wp);
|
create_directories(wp);
|
||||||
#else
|
#else
|
||||||
last_path = dir;
|
|
||||||
if (!exists(last_path))
|
if (!exists(last_path))
|
||||||
create_directories(last_path);
|
create_directories(last_path);
|
||||||
#endif
|
#endif
|
||||||
|
@ -524,29 +522,28 @@ namespace libtorrent
|
||||||
|
|
||||||
int file_index = file_iter - files().begin();
|
int file_index = file_iter - files().begin();
|
||||||
|
|
||||||
// if the file is empty, just create it. But also make sure
|
// ignore files that have priority 0
|
||||||
// the directory exists.
|
if (int(m_file_priority.size()) > file_index
|
||||||
if (file_iter->size == 0 && (int(m_file_priority.size()) <= file_index
|
&& m_file_priority[file_index] == 0) continue;
|
||||||
|| m_file_priority[file_index] > 0))
|
|
||||||
{
|
// ignore pad files
|
||||||
boost::shared_ptr<file> f = m_pool.open_file(this
|
if (file_iter->pad_file) continue;
|
||||||
, m_save_path / file_iter->path, file::read_write, ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
set_error(m_save_path / file_iter->path, ec);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
// don't allocate files with priority 0 or files
|
|
||||||
// that are pad files
|
#if TORRENT_USE_WPATH
|
||||||
if (allocate_files && !file_iter->pad_file
|
fs::wpath file_path = safe_convert(m_save_path / file_iter->path);
|
||||||
&& (int(m_file_priority.size()) <= file_index
|
#else
|
||||||
|| m_file_priority[file_index] > 0))
|
fs::path file_path = m_save_path / file_iter->path;
|
||||||
|
#endif
|
||||||
|
// if the file is empty, just create it either way.
|
||||||
|
// if the file already exists, but is larger than what
|
||||||
|
// it's supposed to be, also truncate it
|
||||||
|
if (allocate_files
|
||||||
|
|| file_iter->size == 0
|
||||||
|
|| (exists(file_path) && file_size(file_path) > file_iter->size))
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
boost::shared_ptr<file> f = m_pool.open_file(this
|
boost::shared_ptr<file> f = m_pool.open_file(this
|
||||||
|
|
Loading…
Reference in New Issue