mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-03 14:14:11 +00:00
Rename namespace dinbpostgres to dindb.
It's so much better!
This commit is contained in:
parent
45fc758915
commit
1fd51f75ba
20 changed files with 64 additions and 64 deletions
|
@ -35,7 +35,7 @@ namespace pq {
|
||||||
class Connection;
|
class Connection;
|
||||||
} //namespace pq
|
} //namespace pq
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
using dinhelp::MaxSizedArray;
|
using dinhelp::MaxSizedArray;
|
||||||
|
|
||||||
struct Settings;
|
struct Settings;
|
||||||
|
@ -146,6 +146,6 @@ namespace dinbpostgres {
|
||||||
this->query_files_in_dir(columns, parDir, parLevel, parSetID, std::bind(pback_func, &flat_list, std::placeholders::_1));
|
this->query_files_in_dir(columns, parDir, parLevel, parSetID, std::bind(pback_func, &flat_list, std::placeholders::_1));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
struct Settings;
|
struct Settings;
|
||||||
|
|
||||||
using IDDescMap = std::map<uint32_t, std::string>;
|
using IDDescMap = std::map<uint32_t, std::string>;
|
||||||
using ConfirmDeleCallback = std::function<bool(const IDDescMap&)>;
|
using ConfirmDeleCallback = std::function<bool(const IDDescMap&)>;
|
||||||
|
|
||||||
void delete_group_from_db ( const Settings& parDB, const std::vector<uint32_t>& parIDs, ConfirmDeleCallback parConf );
|
void delete_group_from_db ( const Settings& parDB, const std::vector<uint32_t>& parIDs, ConfirmDeleCallback parConf );
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace mchlib {
|
||||||
struct TigerHash;
|
struct TigerHash;
|
||||||
} //namespace mchlib
|
} //namespace mchlib
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
struct Settings;
|
struct Settings;
|
||||||
|
|
||||||
struct LocatedItem {
|
struct LocatedItem {
|
||||||
|
@ -49,6 +49,6 @@ namespace dinbpostgres {
|
||||||
std::vector<LocatedItem> locate_in_db ( const Settings& parDB, const mchlib::TigerHash& parSearch, const TagList& parTags );
|
std::vector<LocatedItem> locate_in_db ( const Settings& parDB, const mchlib::TigerHash& parSearch, const TagList& parTags );
|
||||||
std::vector<LocatedSet> locate_sets_in_db ( const Settings& parDB, const std::string& parSearch, bool parCaseInsensitive );
|
std::vector<LocatedSet> locate_sets_in_db ( const Settings& parDB, const std::string& parSearch, bool parCaseInsensitive );
|
||||||
std::vector<LocatedSet> locate_sets_in_db ( const Settings& parDB, const std::string& parSearch, const std::vector<uint32_t>& parSets, bool parCaseInsensitive );
|
std::vector<LocatedSet> locate_sets_in_db ( const Settings& parDB, const std::string& parSearch, const std::vector<uint32_t>& parSets, bool parCaseInsensitive );
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,11 +29,11 @@ namespace mchlib {
|
||||||
struct TigerHash;
|
struct TigerHash;
|
||||||
} //namespace mchlib
|
} //namespace mchlib
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
struct Settings;;
|
struct Settings;;
|
||||||
|
|
||||||
void write_to_db ( const Settings& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature );
|
void write_to_db ( const Settings& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature );
|
||||||
bool read_from_db ( mchlib::FileRecordData& parItem, mchlib::SetRecordDataFull& parSet, const Settings& parDB, const mchlib::TigerHash& parHash );
|
bool read_from_db ( mchlib::FileRecordData& parItem, mchlib::SetRecordDataFull& parSet, const Settings& parDB, const mchlib::TigerHash& parHash );
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
struct Settings {
|
struct Settings {
|
||||||
std::string address;
|
std::string address;
|
||||||
std::string username;
|
std::string username;
|
||||||
|
@ -29,6 +29,6 @@ namespace dinbpostgres {
|
||||||
std::string dbname;
|
std::string dbname;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
};
|
};
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <boost/utility/string_ref.hpp>
|
#include <boost/utility/string_ref.hpp>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
struct Settings;
|
struct Settings;
|
||||||
|
|
||||||
struct OwnerSetInfo {
|
struct OwnerSetInfo {
|
||||||
|
@ -37,6 +37,6 @@ namespace dinbpostgres {
|
||||||
void delete_tags ( const Settings& parDB, const std::vector<std::string>& parRegexes, const std::vector<boost::string_ref>& parTags, OwnerSetInfo parSet );
|
void delete_tags ( const Settings& parDB, const std::vector<std::string>& parRegexes, const std::vector<boost::string_ref>& parTags, OwnerSetInfo parSet );
|
||||||
void delete_all_tags ( const Settings& parDB, const std::vector<uint64_t>& parFiles, OwnerSetInfo parSet );
|
void delete_all_tags ( const Settings& parDB, const std::vector<uint64_t>& parFiles, OwnerSetInfo parSet );
|
||||||
void delete_all_tags ( const Settings& parDB, const std::vector<std::string>& parRegexes, OwnerSetInfo parSet );
|
void delete_all_tags ( const Settings& parDB, const std::vector<std::string>& parRegexes, OwnerSetInfo parSet );
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
namespace dinlib {
|
namespace dinlib {
|
||||||
struct Settings {
|
struct Settings {
|
||||||
dinbpostgres::Settings db;
|
dindb::Settings db;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool load_settings ( const std::string& parPath, Settings& parOut, bool parExpand=true );
|
bool load_settings ( const std::string& parPath, Settings& parOut, bool parExpand=true );
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
namespace {
|
namespace {
|
||||||
const uint32_t g_files_query_limit = 500;
|
const uint32_t g_files_query_limit = 500;
|
||||||
|
|
||||||
|
@ -180,4 +180,4 @@ namespace dinbpostgres {
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
namespace {
|
namespace {
|
||||||
IDDescMap fetch_existing_ids (pq::Connection& parConn, const std::vector<uint32_t>& parIDs) {
|
IDDescMap fetch_existing_ids (pq::Connection& parConn, const std::vector<uint32_t>& parIDs) {
|
||||||
using boost::lexical_cast;
|
using boost::lexical_cast;
|
||||||
|
@ -72,4 +72,4 @@ namespace dinbpostgres {
|
||||||
|
|
||||||
conn.query(oss.str());
|
conn.query(oss.str());
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
namespace {
|
namespace {
|
||||||
const int g_max_results = 200;
|
const int g_max_results = 200;
|
||||||
|
|
||||||
|
@ -137,4 +137,4 @@ namespace dinbpostgres {
|
||||||
auto result = conn.query(query, parSearch, parCaseInsensitive, parSets);
|
auto result = conn.query(query, parSearch, parCaseInsensitive, parSets);
|
||||||
return sets_result_to_vec(std::move(result));
|
return sets_result_to_vec(std::move(result));
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <boost/utility/string_ref.hpp>
|
#include <boost/utility/string_ref.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
namespace {
|
namespace {
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
|
||||||
|
@ -144,4 +144,4 @@ namespace dinbpostgres {
|
||||||
}
|
}
|
||||||
conn.query("COMMIT;");
|
conn.query("COMMIT;");
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "pq/connection.hpp"
|
#include "pq/connection.hpp"
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
void tag_files (const Settings& parDB, const std::vector<uint64_t>& parFiles, const std::vector<boost::string_ref>& parTags, OwnerSetInfo parSet) {
|
void tag_files (const Settings& parDB, const std::vector<uint64_t>& parFiles, const std::vector<boost::string_ref>& parTags, OwnerSetInfo parSet) {
|
||||||
pq::Connection conn(std::string(parDB.username), std::string(parDB.password), std::string(parDB.dbname), std::string(parDB.address), parDB.port);
|
pq::Connection conn(std::string(parDB.username), std::string(parDB.password), std::string(parDB.dbname), std::string(parDB.address), parDB.port);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
@ -152,4 +152,4 @@ namespace dinbpostgres {
|
||||||
conn.query(query, parRegexes);
|
conn.query(query, parRegexes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
namespace YAML {
|
namespace YAML {
|
||||||
template<>
|
template<>
|
||||||
struct convert<dinbpostgres::Settings> {
|
struct convert<dindb::Settings> {
|
||||||
static Node encode (const dinbpostgres::Settings& parSettings) {
|
static Node encode (const dindb::Settings& parSettings) {
|
||||||
Node node;
|
Node node;
|
||||||
node["address"] = parSettings.address;
|
node["address"] = parSettings.address;
|
||||||
node["username"] = parSettings.username;
|
node["username"] = parSettings.username;
|
||||||
|
@ -33,7 +33,7 @@ namespace YAML {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool decode (const Node& parNode, dinbpostgres::Settings& parSettings) {
|
static bool decode (const Node& parNode, dindb::Settings& parSettings) {
|
||||||
if (not parNode.IsMap() or parNode.size() != 5) {
|
if (not parNode.IsMap() or parNode.size() != 5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ namespace dinlib {
|
||||||
auto settings = YAML::LoadFile(path);
|
auto settings = YAML::LoadFile(path);
|
||||||
|
|
||||||
if (settings["db_settings"]) {
|
if (settings["db_settings"]) {
|
||||||
parOut.db = settings["db_settings"].as<dinbpostgres::Settings>();
|
parOut.db = settings["db_settings"].as<dindb::Settings>();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool confirm_delete (const dinbpostgres::IDDescMap& parMap) {
|
bool confirm_delete (const dindb::IDDescMap& parMap) {
|
||||||
for (const auto& itm : parMap) {
|
for (const auto& itm : parMap) {
|
||||||
std::cout << "ID " << itm.first << '\t' << itm.second << '\n';
|
std::cout << "ID " << itm.first << '\t' << itm.second << '\n';
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace {
|
||||||
return (answer.empty() or "y" == answer or "Y" == answer);
|
return (answer.empty() or "y" == answer or "Y" == answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool always_delete (const dinbpostgres::IDDescMap&) {
|
bool always_delete (const dindb::IDDescMap&) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
@ -77,7 +77,7 @@ int main (int parArgc, char* parArgv[]) {
|
||||||
|
|
||||||
const auto ids = vm["groupid"].as<std::vector<uint32_t>>();
|
const auto ids = vm["groupid"].as<std::vector<uint32_t>>();
|
||||||
auto confirm_func = (vm.count("confirm") ? &always_delete : &confirm_delete);
|
auto confirm_func = (vm.count("confirm") ? &always_delete : &confirm_delete);
|
||||||
dinbpostgres::delete_group_from_db(settings.db, ids, confirm_func);
|
dindb::delete_group_from_db(settings.db, ids, confirm_func);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
std::ostream& operator<< (std::ostream& parStream, const LocatedItem& parItem) {
|
std::ostream& operator<< (std::ostream& parStream, const LocatedItem& parItem) {
|
||||||
parStream << parItem.group_id << '\t' << parItem.id << '\t' << parItem.path;
|
parStream << parItem.group_id << '\t' << parItem.id << '\t' << parItem.path;
|
||||||
return parStream;
|
return parStream;
|
||||||
|
@ -41,7 +41,7 @@ namespace dinbpostgres {
|
||||||
'\t' << parItem.files_count << '\t' << dircount;
|
'\t' << parItem.files_count << '\t' << dircount;
|
||||||
return parStream;
|
return parStream;
|
||||||
}
|
}
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::vector<boost::string_ref> extract_tags (const boost::program_options::variables_map& parVM) {
|
std::vector<boost::string_ref> extract_tags (const boost::program_options::variables_map& parVM) {
|
||||||
|
@ -81,22 +81,22 @@ int main (int parArgc, char* parArgv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("set")) {
|
if (vm.count("set")) {
|
||||||
const auto results = dinbpostgres::locate_sets_in_db(settings.db, vm["substring"].as<std::string>(), not not vm.count("case-insensitive"));
|
const auto results = dindb::locate_sets_in_db(settings.db, vm["substring"].as<std::string>(), not not vm.count("case-insensitive"));
|
||||||
std::copy(results.begin(), results.end(), std::ostream_iterator<dinbpostgres::LocatedSet>(std::cout, "\n"));
|
std::copy(results.begin(), results.end(), std::ostream_iterator<dindb::LocatedSet>(std::cout, "\n"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::vector<dinbpostgres::LocatedItem> results;
|
std::vector<dindb::LocatedItem> results;
|
||||||
const std::vector<boost::string_ref> tags = extract_tags(vm);
|
const std::vector<boost::string_ref> tags = extract_tags(vm);
|
||||||
|
|
||||||
if (vm.count("byhash")) {
|
if (vm.count("byhash")) {
|
||||||
const auto hash = din::hash(vm["substring"].as<std::string>());
|
const auto hash = din::hash(vm["substring"].as<std::string>());
|
||||||
results = dinbpostgres::locate_in_db(settings.db, hash, tags);
|
results = dindb::locate_in_db(settings.db, hash, tags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const auto search_regex = g2r::convert(vm["substring"].as<std::string>(), not vm.count("case-insensitive"));
|
const auto search_regex = g2r::convert(vm["substring"].as<std::string>(), not vm.count("case-insensitive"));
|
||||||
results = dinbpostgres::locate_in_db(settings.db, search_regex, tags);
|
results = dindb::locate_in_db(settings.db, search_regex, tags);
|
||||||
}
|
}
|
||||||
std::copy(results.begin(), results.end(), std::ostream_iterator<dinbpostgres::LocatedItem>(std::cout, "\n"));
|
std::copy(results.begin(), results.end(), std::ostream_iterator<dindb::LocatedItem>(std::cout, "\n"));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace din {
|
||||||
}
|
}
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
|
||||||
ListDirContent::ListDirContent (dinbpostgres::DBSource* parDB) :
|
ListDirContent::ListDirContent (dindb::DBSource* parDB) :
|
||||||
m_cache(g_max_cached_lists),
|
m_cache(g_max_cached_lists),
|
||||||
m_db(parDB)
|
m_db(parDB)
|
||||||
{
|
{
|
||||||
|
@ -86,13 +86,13 @@ namespace din {
|
||||||
//Requested item is not cached, so we need to query the db now
|
//Requested item is not cached, so we need to query the db now
|
||||||
if (parDir.points_to_group()) {
|
if (parDir.points_to_group()) {
|
||||||
auto sets_ids = m_db->sets();
|
auto sets_ids = m_db->sets();
|
||||||
auto sets_info = m_db->set_details<dinbpostgres::SetDetail_ID, dinbpostgres::SetDetail_Desc, dinbpostgres::SetDetail_CreeationDate>(sets_ids);
|
auto sets_info = m_db->set_details<dindb::SetDetail_ID, dindb::SetDetail_Desc, dindb::SetDetail_CreeationDate>(sets_ids);
|
||||||
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(sets_info)));
|
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(sets_info)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto path_prefix = parDir.file_path();
|
auto path_prefix = parDir.file_path();
|
||||||
const auto set_id = parDir.group_id();
|
const auto set_id = parDir.group_id();
|
||||||
auto files_info = m_db->file_details<dinbpostgres::FileDetail_Path>(set_id, parDir.level() + 1, path_prefix);
|
auto files_info = m_db->file_details<dindb::FileDetail_Path>(set_id, parDir.level() + 1, path_prefix);
|
||||||
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(files_info)));
|
m_cache.push_back(std::make_pair(curr_path, db_result_to_vec(files_info)));
|
||||||
}
|
}
|
||||||
return last_cached_item(curr_path);
|
return last_cached_item(curr_path);
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dinbpostgres {
|
namespace dindb {
|
||||||
class DBSource;
|
class DBSource;
|
||||||
} //namespace dinbpostgres
|
} //namespace dindb
|
||||||
|
|
||||||
namespace din {
|
namespace din {
|
||||||
class EntryPath;
|
class EntryPath;
|
||||||
|
@ -34,7 +34,7 @@ namespace din {
|
||||||
using ListType = std::vector<std::string>;
|
using ListType = std::vector<std::string>;
|
||||||
using CachedItemType = std::pair<std::string, ListType>;
|
using CachedItemType = std::pair<std::string, ListType>;
|
||||||
public:
|
public:
|
||||||
explicit ListDirContent ( dinbpostgres::DBSource* parDB );
|
explicit ListDirContent ( dindb::DBSource* parDB );
|
||||||
~ListDirContent ( void ) noexcept = default;
|
~ListDirContent ( void ) noexcept = default;
|
||||||
|
|
||||||
const ListType& ls ( const EntryPath& parDir ) const;
|
const ListType& ls ( const EntryPath& parDir ) const;
|
||||||
|
@ -44,7 +44,7 @@ namespace din {
|
||||||
const ListType& last_cached_item ( const std::string& parCurrPath ) const;
|
const ListType& last_cached_item ( const std::string& parCurrPath ) const;
|
||||||
|
|
||||||
mutable boost::circular_buffer<CachedItemType> m_cache;
|
mutable boost::circular_buffer<CachedItemType> m_cache;
|
||||||
dinbpostgres::DBSource* m_db;
|
dindb::DBSource* m_db;
|
||||||
};
|
};
|
||||||
} //namespace din
|
} //namespace din
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <boost/range/algorithm/copy.hpp>
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void do_navigation ( dinbpostgres::DBSource& parDB );
|
void do_navigation ( dindb::DBSource& parDB );
|
||||||
|
|
||||||
bool on_exit ( void );
|
bool on_exit ( void );
|
||||||
void on_pwd ( const din::EntryPath& parDirMan );
|
void on_pwd ( const din::EntryPath& parDirMan );
|
||||||
|
@ -61,7 +61,7 @@ int main (int parArgc, char* parArgv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dinbpostgres::DBSource db_source(settings.db);
|
dindb::DBSource db_source(settings.db);
|
||||||
|
|
||||||
do_navigation(db_source);
|
do_navigation(db_source);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -81,7 +81,7 @@ namespace {
|
||||||
boost::copy(ls_result, std::ostream_iterator<std::string>(std::cout, "\n"));
|
boost::copy(ls_result, std::ostream_iterator<std::string>(std::cout, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_navigation (dinbpostgres::DBSource& parDB) {
|
void do_navigation (dindb::DBSource& parDB) {
|
||||||
const std::string prompt;
|
const std::string prompt;
|
||||||
din::ListDirContent ls(&parDB);
|
din::ListDirContent ls(&parDB);
|
||||||
din::LineReader lines(&ls);
|
din::LineReader lines(&ls);
|
||||||
|
@ -92,7 +92,7 @@ namespace {
|
||||||
din::EntryPath dir_man;
|
din::EntryPath dir_man;
|
||||||
proc.add_command("exit", &on_exit, 0);
|
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("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(&dinbpostgres::DBSource::disconnect, &parDB)), 0);
|
proc.add_command("disconnect", std::function<void()>(std::bind(&dindb::DBSource::disconnect, &parDB)), 0);
|
||||||
proc.add_command("pwd", std::function<void()>(std::bind(&on_pwd, std::ref(dir_man))), 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);
|
proc.add_command("ls", std::function<void()>(std::bind(on_ls, std::ref(ls), std::ref(dir_man))), 0);
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool add_to_db ( const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSet, const dinbpostgres::Settings& parDBSettings, bool parForce=false );
|
bool add_to_db ( const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSet, const dindb::Settings& parDBSettings, bool parForce=false );
|
||||||
#if defined(WITH_PROGRESS_FEEDBACK)
|
#if defined(WITH_PROGRESS_FEEDBACK)
|
||||||
void print_progress ( const boost::string_ref parPath, uint64_t parFileBytes, uint64_t parTotalBytes, uint32_t parFileNum, std::size_t& parClearCount );
|
void print_progress ( const boost::string_ref parPath, uint64_t parFileBytes, uint64_t parTotalBytes, uint32_t parFileNum, std::size_t& parClearCount );
|
||||||
#endif
|
#endif
|
||||||
|
@ -115,7 +115,7 @@ int main (int parArgc, char* parArgv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool add_to_db (const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSet, const dinbpostgres::Settings& parDBSettings, bool parForce) {
|
bool add_to_db (const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSet, const dindb::Settings& parDBSettings, bool parForce) {
|
||||||
using mchlib::FileRecordData;
|
using mchlib::FileRecordData;
|
||||||
using mchlib::SetRecordDataFull;
|
using mchlib::SetRecordDataFull;
|
||||||
using mchlib::SetRecordData;
|
using mchlib::SetRecordData;
|
||||||
|
@ -124,7 +124,7 @@ namespace {
|
||||||
const auto& first_hash = parData.front().hash;
|
const auto& first_hash = parData.front().hash;
|
||||||
FileRecordData itm;
|
FileRecordData itm;
|
||||||
SetRecordDataFull set;
|
SetRecordDataFull set;
|
||||||
const bool already_in_db = dinbpostgres::read_from_db(itm, set, parDBSettings, first_hash);
|
const bool already_in_db = dindb::read_from_db(itm, set, parDBSettings, first_hash);
|
||||||
if (already_in_db) {
|
if (already_in_db) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ namespace {
|
||||||
const auto app_signature = dinlib::dindexer_signature();
|
const auto app_signature = dinlib::dindexer_signature();
|
||||||
const auto lib_signature = mchlib::lib_signature();
|
const auto lib_signature = mchlib::lib_signature();
|
||||||
const std::string signature = std::string(app_signature.data(), app_signature.size()) + "/" + std::string(lib_signature.data(), lib_signature.size());
|
const std::string signature = std::string(app_signature.data(), app_signature.size()) + "/" + std::string(lib_signature.data(), lib_signature.size());
|
||||||
dinbpostgres::write_to_db(parDBSettings, parData, set_data, signature);
|
dindb::write_to_db(parDBSettings, parData, set_data, signature);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ namespace {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
dinbpostgres::OwnerSetInfo make_owner_set_info (const boost::program_options::variables_map& parVM) {
|
dindb::OwnerSetInfo make_owner_set_info (const boost::program_options::variables_map& parVM) {
|
||||||
dinbpostgres::OwnerSetInfo set_info;
|
dindb::OwnerSetInfo set_info;
|
||||||
if (parVM.count("set")) {
|
if (parVM.count("set")) {
|
||||||
set_info.is_valid = true;
|
set_info.is_valid = true;
|
||||||
set_info.group_id = parVM["set"].as<uint32_t>();
|
set_info.group_id = parVM["set"].as<uint32_t>();
|
||||||
|
@ -60,11 +60,11 @@ namespace {
|
||||||
return set_info;
|
return set_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tag_files (const dinbpostgres::Settings& parDB, TaggingMode parMode, const boost::program_options::variables_map& parVM, const std::vector<boost::string_ref>& parTags) {
|
int tag_files (const dindb::Settings& parDB, TaggingMode parMode, const boost::program_options::variables_map& parVM, const std::vector<boost::string_ref>& parTags) {
|
||||||
using boost::lexical_cast;
|
using boost::lexical_cast;
|
||||||
using boost::string_ref;
|
using boost::string_ref;
|
||||||
|
|
||||||
const dinbpostgres::OwnerSetInfo set_info = make_owner_set_info(parVM);
|
const dindb::OwnerSetInfo set_info = make_owner_set_info(parVM);
|
||||||
|
|
||||||
switch (parMode) {
|
switch (parMode) {
|
||||||
case TaggingMode::ID:
|
case TaggingMode::ID:
|
||||||
|
@ -73,14 +73,14 @@ namespace {
|
||||||
std::vector<uint64_t> ids;
|
std::vector<uint64_t> ids;
|
||||||
ids.reserve(ids_string.size());
|
ids.reserve(ids_string.size());
|
||||||
std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast<uint64_t, string_ref>);
|
std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast<uint64_t, string_ref>);
|
||||||
dinbpostgres::tag_files(parDB, ids, parTags, set_info);
|
dindb::tag_files(parDB, ids, parTags, set_info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TaggingMode::Glob:
|
case TaggingMode::Glob:
|
||||||
{
|
{
|
||||||
const auto regexes(globs_to_regex_list(parVM["globs"].as<std::vector<std::string>>()));
|
const auto regexes(globs_to_regex_list(parVM["globs"].as<std::vector<std::string>>()));
|
||||||
dinbpostgres::tag_files(parDB, regexes, parTags, set_info);
|
dindb::tag_files(parDB, regexes, parTags, set_info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int delete_tags (const dinbpostgres::Settings& parDB, TaggingMode parMode, const boost::program_options::variables_map& parVM, const std::vector<boost::string_ref>& parTags) {
|
int delete_tags (const dindb::Settings& parDB, TaggingMode parMode, const boost::program_options::variables_map& parVM, const std::vector<boost::string_ref>& parTags) {
|
||||||
using boost::lexical_cast;
|
using boost::lexical_cast;
|
||||||
using boost::string_ref;
|
using boost::string_ref;
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ namespace {
|
||||||
ids.reserve(ids_string.size());
|
ids.reserve(ids_string.size());
|
||||||
std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast<uint64_t, string_ref>);
|
std::transform(ids_string.begin(), ids_string.end(), std::back_inserter(ids), &lexical_cast<uint64_t, string_ref>);
|
||||||
if (parVM.count("alltags"))
|
if (parVM.count("alltags"))
|
||||||
dinbpostgres::delete_all_tags(parDB, ids, make_owner_set_info(parVM));
|
dindb::delete_all_tags(parDB, ids, make_owner_set_info(parVM));
|
||||||
else
|
else
|
||||||
dinbpostgres::delete_tags(parDB, ids, parTags, make_owner_set_info(parVM));
|
dindb::delete_tags(parDB, ids, parTags, make_owner_set_info(parVM));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@ namespace {
|
||||||
{
|
{
|
||||||
const auto regexes(globs_to_regex_list(parVM["globs"].as<std::vector<std::string>>()));
|
const auto regexes(globs_to_regex_list(parVM["globs"].as<std::vector<std::string>>()));
|
||||||
if (parVM.count("alltags"))
|
if (parVM.count("alltags"))
|
||||||
dinbpostgres::delete_all_tags(parDB, regexes, make_owner_set_info(parVM));
|
dindb::delete_all_tags(parDB, regexes, make_owner_set_info(parVM));
|
||||||
else
|
else
|
||||||
dinbpostgres::delete_tags(parDB, regexes, parTags, make_owner_set_info(parVM));
|
dindb::delete_tags(parDB, regexes, parTags, make_owner_set_info(parVM));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue