mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-13 15:54:11 +00:00
Save and read label and uuid to the database
This commit is contained in:
parent
55a61526dc
commit
7117ff7be2
11 changed files with 42 additions and 20 deletions
|
@ -117,7 +117,7 @@ namespace dindb {
|
|||
dindb::delete_group_from_db(*m_conn, parIDs, parConf);
|
||||
}
|
||||
|
||||
void BackendPostgreSql::write_files (const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature) {
|
||||
void BackendPostgreSql::write_files (const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSetData, const std::string& parSignature) {
|
||||
dindb::write_to_db(*m_conn, parData, parSetData, parSignature);
|
||||
}
|
||||
|
||||
|
@ -145,8 +145,13 @@ namespace dindb {
|
|||
return dindb::find_all_sets(*m_conn);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 3>> BackendPostgreSql::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
return dindb::find_set_details<dindb::SetDetail_ID, dindb::SetDetail_Desc, dindb::SetDetail_CreeationDate>(*m_conn, parSets);
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> BackendPostgreSql::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
return dindb::find_set_details<
|
||||
dindb::SetDetail_ID,
|
||||
dindb::SetDetail_Desc,
|
||||
dindb::SetDetail_CreeationDate,
|
||||
dindb::SetDetail_DiskLabel
|
||||
>(*m_conn, parSets);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> BackendPostgreSql::find_file_details (GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace dindb {
|
|||
|
||||
virtual void delete_group ( const std::vector<uint32_t>& parIDs, ConfirmDeleCallback parConf ) override;
|
||||
|
||||
virtual void write_files ( const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature ) override;
|
||||
virtual void write_files ( const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSetData, const std::string& parSignature ) override;
|
||||
virtual bool search_file_by_hash ( mchlib::FileRecordData& parItem, mchlib::SetRecordDataFull& parSet, const mchlib::TigerHash& parHash ) override;
|
||||
|
||||
virtual std::vector<LocatedItem> locate_in_db ( const std::string& parSearch, const TagList& parTags ) override;
|
||||
|
@ -55,7 +55,7 @@ namespace dindb {
|
|||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSearch, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive ) override;
|
||||
|
||||
virtual std::vector<GroupIDType> find_all_sets ( void ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 3>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) override;
|
||||
virtual std::vector<std::string> find_paths_starting_by ( GroupIDType parGroupID, uint16_t parLevel, boost::string_ref parPath ) override;
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ namespace dindb {
|
|||
{SetDetail_Type, "type"},
|
||||
{SetDetail_CreeationDate, "creation"},
|
||||
{SetDetail_AppName, "app_name"},
|
||||
{SetDetail_ID, "id"}
|
||||
{SetDetail_ID, "id"},
|
||||
{SetDetail_DiskLabel, "disk_label"},
|
||||
{SetDetail_FSUuid, "fs_uuid"}
|
||||
};
|
||||
const FileDetailsMap g_file_details_map {
|
||||
{FileDetail_ID, "id"},
|
||||
|
|
|
@ -44,7 +44,9 @@ namespace dindb {
|
|||
SetDetail_Type = 0x02,
|
||||
SetDetail_CreeationDate = 0x04,
|
||||
SetDetail_AppName = 0x08,
|
||||
SetDetail_ID = 0x10
|
||||
SetDetail_ID = 0x10,
|
||||
SetDetail_DiskLabel = 0x20,
|
||||
SetDetail_FSUuid = 0x40
|
||||
};
|
||||
|
||||
enum FileDetails {
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace dindb {
|
|||
|
||||
{
|
||||
auto resultset = parDB.query(
|
||||
"SELECT \"desc\",\"type\",\"disk_number\" FROM sets WHERE \"id\"=$1;",
|
||||
"SELECT \"desc\",\"type\",\"disk_number\",\"fs_uuid\",\"disk_label\" FROM sets WHERE \"id\"=$1;",
|
||||
group_id
|
||||
);
|
||||
if (resultset.empty()) {
|
||||
|
@ -77,11 +77,13 @@ namespace dindb {
|
|||
parSet.type = lexical_cast<char>(row["type"]);
|
||||
parSet.name = row["desc"];
|
||||
parSet.disk_number = lexical_cast<uint32_t>(row["disk_number"]);
|
||||
parSet.fs_uuid = row["fs_uuid"];
|
||||
parSet.disk_label = row["disk_label"];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void write_to_db (pq::Connection& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature) {
|
||||
void write_to_db (pq::Connection& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSetData, const std::string& parSignature) {
|
||||
using std::chrono::system_clock;
|
||||
using boost::lexical_cast;
|
||||
|
||||
|
@ -96,12 +98,14 @@ namespace dindb {
|
|||
{
|
||||
auto id_res = parDB.query("INSERT INTO \"sets\" "
|
||||
"(\"desc\",\"type\",\"app_name\""
|
||||
",\"content_type\") "
|
||||
"VALUES ($1, $2, $3, $4) RETURNING \"id\";",
|
||||
",\"content_type\",\"fs_uuid\",\"disk_label\") "
|
||||
"VALUES ($1, $2, $3, $4, $5, $6) RETURNING \"id\";",
|
||||
parSetData.name,
|
||||
boost::string_ref(&parSetData.type, 1),
|
||||
parSignature,
|
||||
boost::string_ref(&parSetData.content_type, 1)
|
||||
boost::string_ref(&parSetData.content_type, 1),
|
||||
parSetData.fs_uuid,
|
||||
parSetData.disk_label
|
||||
);
|
||||
assert(id_res.size() == 1);
|
||||
assert(id_res[0].size() == 1);
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace pq {
|
|||
namespace dindb {
|
||||
struct Settings;;
|
||||
|
||||
void write_to_db ( pq::Connection& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature );
|
||||
void write_to_db ( pq::Connection& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSetData, const std::string& parSignature );
|
||||
bool read_from_db ( mchlib::FileRecordData& parItem, mchlib::SetRecordDataFull& parSet, pq::Connection& parDB, const mchlib::TigerHash& parHash );
|
||||
} //namespace dindb
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue