mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 07:28:39 +00:00
lt 2879-storage cleanup and truncating files that are larger than they should be
This commit is contained in:
parent
da6594d138
commit
c1be1f3072
1 changed files with 13 additions and 24 deletions
|
@ -505,44 +505,36 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the file is empty, just create it. But also make sure
|
|
||||||
// the directory exists.
|
|
||||||
if (file_iter->size == 0)
|
|
||||||
{
|
|
||||||
boost::shared_ptr<file> f = m_pool.open_file(this
|
|
||||||
, m_save_path / file_iter->path, file::in | file::out, 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
|
|
||||||
int file_index = file_iter - files().begin();
|
#if TORRENT_USE_WPATH
|
||||||
if (allocate_files && (int(m_file_priority.size()) <= file_index
|
fs::wpath file_path = safe_convert(m_save_path / file_iter->path);
|
||||||
|| m_file_priority[file_index] > 0))
|
#else
|
||||||
|
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
|
||||||
|
@ -2280,10 +2272,7 @@ namespace libtorrent
|
||||||
#else
|
#else
|
||||||
&& m_storage->error() != error_code(ENOENT, get_posix_category()))
|
&& m_storage->error() != error_code(ENOENT, get_posix_category()))
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
std::cerr << m_storage->error().message() << std::endl;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue