mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-08-18 15:29:48 +00:00
Re-enable navigate in the postgre plugin.
This commit is contained in:
parent
780cd9b0ca
commit
dfe3655296
11 changed files with 238 additions and 238 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "listdircontent.hpp"
|
||||
#include "entrypath.hpp"
|
||||
#include "db/dbsource.hpp"
|
||||
#include "backends/db_backend.hpp"
|
||||
#include "helpers/infix_iterator.hpp"
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
|
@ -68,7 +68,7 @@ namespace din {
|
|||
}
|
||||
} //unnamed namespace
|
||||
|
||||
ListDirContent::ListDirContent (dindb::DBSource* parDB) :
|
||||
ListDirContent::ListDirContent (dindb::Backend* parDB) :
|
||||
m_cache(g_max_cached_lists),
|
||||
m_db(parDB)
|
||||
{
|
||||
|
@ -85,14 +85,14 @@ namespace din {
|
|||
|
||||
//Requested item is not cached, so we need to query the db now
|
||||
if (parDir.points_to_group()) {
|
||||
auto sets_ids = m_db->sets();
|
||||
auto sets_info = m_db->set_details<dindb::SetDetail_ID, dindb::SetDetail_Desc, dindb::SetDetail_CreeationDate>(sets_ids);
|
||||
auto sets_ids = m_db->find_all_sets();
|
||||
auto sets_info = m_db->find_set_details(sets_ids);
|
||||
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(sets_info)));
|
||||
}
|
||||
else {
|
||||
auto path_prefix = parDir.file_path();
|
||||
const auto set_id = parDir.group_id();
|
||||
auto files_info = m_db->file_details<dindb::FileDetail_Path>(set_id, parDir.level() + 1, path_prefix);
|
||||
auto files_info = m_db->find_file_details(set_id, parDir.level() + 1, path_prefix);
|
||||
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(files_info)));
|
||||
}
|
||||
return last_cached_item(curr_path);
|
||||
|
@ -115,7 +115,7 @@ namespace din {
|
|||
else {
|
||||
const auto set_id = parDir.group_id();
|
||||
const auto path_prefix = parDir.file_path();
|
||||
auto file_list = m_db->paths_starting_by(set_id, parDir.level(), path_prefix);
|
||||
auto file_list = m_db->find_paths_starting_by(set_id, parDir.level(), path_prefix);
|
||||
for (auto& file_item : file_list) {
|
||||
file_item = EntryPath(file_item)[return_level];
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace dindb {
|
||||
class DBSource;
|
||||
class Backend;
|
||||
} //namespace dindb
|
||||
|
||||
namespace din {
|
||||
|
@ -34,7 +34,7 @@ namespace din {
|
|||
using ListType = std::vector<std::string>;
|
||||
using CachedItemType = std::pair<std::string, ListType>;
|
||||
public:
|
||||
explicit ListDirContent ( dindb::DBSource* parDB );
|
||||
explicit ListDirContent ( dindb::Backend* parDB );
|
||||
~ListDirContent ( void ) noexcept = default;
|
||||
|
||||
const ListType& ls ( const EntryPath& parDir ) const;
|
||||
|
@ -44,7 +44,7 @@ namespace din {
|
|||
const ListType& last_cached_item ( const std::string& parCurrPath ) const;
|
||||
|
||||
mutable boost::circular_buffer<CachedItemType> m_cache;
|
||||
dindb::DBSource* m_db;
|
||||
dindb::Backend* m_db;
|
||||
};
|
||||
} //namespace din
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "commandprocessor.hpp"
|
||||
#include "dindexer-common/settings.hpp"
|
||||
#include "entrypath.hpp"
|
||||
#include "db/dbsource.hpp"
|
||||
#include "dindexerConfig.h"
|
||||
#include "linereader.hpp"
|
||||
#include "listdircontent.hpp"
|
||||
|
@ -31,7 +30,7 @@
|
|||
#include <boost/range/algorithm/copy.hpp>
|
||||
|
||||
namespace {
|
||||
void do_navigation ( dindb::DBSource& parDB );
|
||||
void do_navigation ( dindb::Backend& parDB );
|
||||
|
||||
bool on_exit ( void );
|
||||
void on_pwd ( const din::EntryPath& parDirMan );
|
||||
|
@ -60,10 +59,11 @@ int main (int parArgc, char* parArgv[]) {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
//TODO: throw if plugin loading failed
|
||||
assert(settings.backend_plugin.name() == settings.backend_name);
|
||||
assert(settings.backend_plugin.is_loaded());
|
||||
|
||||
dindb::DBSource db_source(settings.db);
|
||||
|
||||
do_navigation(db_source);
|
||||
do_navigation(settings.backend_plugin.backend());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ namespace {
|
|||
boost::copy(ls_result, std::ostream_iterator<std::string>(std::cout, "\n"));
|
||||
}
|
||||
|
||||
void do_navigation (dindb::DBSource& parDB) {
|
||||
void do_navigation (dindb::Backend& parDB) {
|
||||
const std::string prompt;
|
||||
din::ListDirContent ls(&parDB);
|
||||
din::LineReader lines(&ls);
|
||||
|
@ -92,7 +92,7 @@ namespace {
|
|||
din::EntryPath dir_man;
|
||||
proc.add_command("exit", &on_exit, 0);
|
||||
proc.add_command("cd", std::function<void(const std::string&)>(std::bind(&din::EntryPath::push_piece, &dir_man, std::placeholders::_1)), 1);
|
||||
proc.add_command("disconnect", std::function<void()>(std::bind(&dindb::DBSource::disconnect, &parDB)), 0);
|
||||
proc.add_command("disconnect", std::function<void()>(std::bind(&dindb::Backend::disconnect, std::ref(parDB))), 0);
|
||||
proc.add_command("pwd", std::function<void()>(std::bind(&on_pwd, std::ref(dir_man))), 0);
|
||||
proc.add_command("ls", std::function<void()>(std::bind(on_ls, std::ref(ls), std::ref(dir_man))), 0);
|
||||
do {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue