From 05d7028f616dec2f9b2d58c3957a9f40017527e3 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Wed, 13 May 2009 17:25:19 +0000 Subject: [PATCH] * Added support for using posix_fallocate on newly resized files. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1090 e378c898-3ddf-0310-93e7-cc216c733640 --- src/command_local.cc | 2 ++ src/core/download_list.cc | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/command_local.cc b/src/command_local.cc index 4e2befd4..f81fbace 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -165,6 +165,8 @@ initialize_command_local() { ADD_COMMAND_VOID("system.hostname", rak::ptr_fun(&system_hostname)); ADD_COMMAND_VOID("system.pid", rak::ptr_fun(&getpid)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.file_allocate", "value", (int64_t)0)); + ADD_COMMAND_VOID("system.file_status_cache.size", rak::make_mem_fun((utils::FileStatusCache::base_type*)control->core()->file_status_cache(), &utils::FileStatusCache::size)); ADD_COMMAND_VOID("system.file_status_cache.prune", rak::make_mem_fun(control->core()->file_status_cache(), &utils::FileStatusCache::prune)); diff --git a/src/core/download_list.cc b/src/core/download_list.cc index dff39f07..7272397b 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -215,7 +215,12 @@ DownloadList::open_throw(Download* download) { if (download->download()->is_open()) return; - download->download()->open(download->resume_flags()); + int openFlags = download->resume_flags(); + + if (rpc::call_command_value("system.file_allocate")) + openFlags |= torrent::Download::open_enable_fallocate; + + download->download()->open(openFlags); rpc::commands.call_catch("event.download.opened", rpc::make_target(download), torrent::Object(), "Download event action failed: "); }