mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 20:52:30 +00:00
* Automatically prune the file status cache every day.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1025 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include "rpc/command_slot.h"
|
||||
#include "rpc/command_variable.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
#include "utils/file_status_cache.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
@@ -127,6 +128,9 @@ initialize_command_local() {
|
||||
ADD_COMMAND_VOID("system.hostname", rak::ptr_fun(&system_hostname));
|
||||
ADD_COMMAND_VOID("system.pid", rak::ptr_fun(&getpid));
|
||||
|
||||
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));
|
||||
|
||||
ADD_COMMAND_VALUE_SET_OCT("system.", "umask", std::ptr_fun(&umask));
|
||||
ADD_COMMAND_STRING_PREFIX("system.", "cwd", std::ptr_fun(system_set_cwd), rak::ptr_fun(&system_get_cwd));
|
||||
|
||||
|
||||
@@ -236,6 +236,7 @@ main(int argc, char** argv) {
|
||||
|
||||
"schedule = session_save,1800,1800,session_save=\n"
|
||||
"schedule = low_diskspace,5,60,close_low_diskspace=500M\n"
|
||||
"schedule = prune_file_status,3600,86400,system.file_status_cache.prune=\n"
|
||||
|
||||
"encryption=allow_incoming,prefer_plaintext,enable_retry\n"
|
||||
);
|
||||
|
||||
@@ -68,4 +68,17 @@ FileStatusCache::insert(const std::string& path, int flags) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
FileStatusCache::prune() {
|
||||
iterator itr = begin();
|
||||
|
||||
while (itr != end()) {
|
||||
rak::file_stat fs;
|
||||
iterator tmp = itr++;
|
||||
|
||||
if (!fs.update(rak::path_expand(tmp->first)) || tmp->second.m_mtime != (uint32_t)fs.modified_time())
|
||||
base_type::erase(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,10 +73,9 @@ public:
|
||||
|
||||
// Add a function for pruning a sorted list of paths.
|
||||
|
||||
// Function for removing entries in a container that shouldn't be
|
||||
// there based on some parameters.
|
||||
|
||||
// Function for pruning entries with different mtime or not existing.
|
||||
// Function for pruning entries that no longer points to a file, or
|
||||
// has a different mtime.
|
||||
void prune();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user