1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-29 01:33:46 +00:00

Add app_name column to sets.

This commit is contained in:
King_DuckZ 2016-01-21 20:30:38 +00:00
parent 9f3b27f0b5
commit 913cdbd59d
12 changed files with 171 additions and 13 deletions

View file

@ -4,7 +4,7 @@
-- Dumped from database version 9.4.5
-- Dumped by pg_dump version 9.4.5
-- Started on 2016-01-07 15:10:56 GMT
-- Started on 2016-01-21 20:29:42 GMT
SET statement_timeout = 0;
SET lock_timeout = 0;
@ -141,6 +141,7 @@ CREATE TABLE sets (
type character(1) DEFAULT 'D'::bpchar NOT NULL,
disk_number integer DEFAULT 0 NOT NULL,
creation timestamp with time zone DEFAULT now() NOT NULL,
app_name character varying NOT NULL,
CONSTRAINT chk_sets_type CHECK (((((((((type = 'C'::bpchar) OR (type = 'D'::bpchar)) OR (type = 'V'::bpchar)) OR (type = 'B'::bpchar)) OR (type = 'F'::bpchar)) OR (type = 'H'::bpchar)) OR (type = 'Z'::bpchar)) OR (type = 'O'::bpchar)))
);
@ -282,7 +283,7 @@ GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
-- Completed on 2016-01-07 15:11:05 GMT
-- Completed on 2016-01-21 20:29:44 GMT
--
-- PostgreSQL database dump complete

View file

@ -0,0 +1,27 @@
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef idD68F614BAF5D480A90EE41731BDEE822
#define idD68F614BAF5D480A90EE41731BDEE822
#include <boost/utility/string_ref.hpp>
namespace dinlib {
boost::string_ref dindexer_signature ( void );
} //namespace dinlib
#endif

View file

@ -0,0 +1,27 @@
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef id32001138F12F4B5797C5883CDE8C2BDF
#define id32001138F12F4B5797C5883CDE8C2BDF
#include <boost/utility/string_ref.hpp>
namespace mchlib {
boost::string_ref lib_signature ( void );
} //namespace mchlib
#endif

View file

@ -0,0 +1,24 @@
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef id8B9FF1807C05459DAE8CD05312147416
#define id8B9FF1807C05459DAE8CD05312147416
#define STRINGIZE_IMPL(s) #s
#define STRINGIZE(s) STRINGIZE_IMPL(s)
#endif

View file

@ -5,6 +5,7 @@ add_library(${PROJECT_NAME}
mediatypes.cpp
settings.cpp
validationerror.cpp
common_info.cpp
)
target_include_directories(${PROJECT_NAME}

View file

@ -18,13 +18,11 @@
#include "dindexer-common/commandline.hpp"
#include "dindexerConfig.h"
#include "helpers/lengthof.h"
#include "helpers/stringize.h"
#include <boost/program_options.hpp>
#include <ostream>
#include <utility>
#define STRINGIZE_IMPL(s) #s
#define STRINGIZE(s) STRINGIZE_IMPL(s)
namespace po = boost::program_options;
namespace dinlib {

View file

@ -0,0 +1,38 @@
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#include "dindexer-common/common_info.hpp"
#include "dindexerConfig.h"
#include "helpers/stringize.h"
namespace dinlib {
namespace {
const char* const g_signature_string =
PROGRAM_NAME "_v"
STRINGIZE(VERSION_MAJOR) "."
STRINGIZE(VERSION_MINOR) "."
STRINGIZE(VERSION_PATCH)
#if VERSION_BETA
"b"
#endif
;
} //unnamed namespace
boost::string_ref dindexer_signature() {
return boost::string_ref(g_signature_string);
}
} //namespace dinlib

View file

@ -12,6 +12,7 @@ add_library(${PROJECT_NAME} SHARED
filesearcher.cpp
discinfo.cpp
mediatype.cpp
machinery_info.cpp
)
#target_include_directories(${PROJECT_NAME}

View file

@ -0,0 +1,33 @@
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#include "dindexer-machinery/machinery_info.hpp"
#include "dindexerConfig.h"
#include "helpers/stringize.h"
namespace mchlib {
boost::string_ref lib_signature() {
return boost::string_ref("machinery_v"
STRINGIZE(VERSION_MAJOR) "."
STRINGIZE(VERSION_MINOR) "."
STRINGIZE(VERSION_PATCH)
#if VERSION_BETA
"b"
#endif
);
}
} //namespace mchlib

View file

@ -1,4 +1,4 @@
/* Copyright 2015, Michele Santullo
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
@ -82,7 +82,7 @@ namespace din {
return true;
}
void write_to_db (const dinlib::SettingsDB& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData) {
void write_to_db (const dinlib::SettingsDB& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData, const std::string& parSignature) {
using std::chrono::system_clock;
using boost::lexical_cast;
@ -96,9 +96,12 @@ namespace din {
conn.query("BEGIN;");
uint32_t new_group_id;
{
auto id_res = conn.query("INSERT INTO \"sets\" (\"desc\",\"type\") VALUES ($1, $2) RETURNING \"id\";",
auto id_res = conn.query("INSERT INTO \"sets\" "
"(\"desc\",\"type\", \"app_name\") "
"VALUES ($1, $2) RETURNING \"id\";",
parSetData.name,
std::string(1, parSetData.type)
std::string(1, parSetData.type),
parSignature
);
assert(id_res.size() == 1);
assert(id_res[0].size() == 1);

View file

@ -1,4 +1,4 @@
/* Copyright 2015, Michele Santullo
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
@ -34,7 +34,7 @@ namespace mchlib {
} //namespace mchlib
namespace din {
void write_to_db ( const dinlib::SettingsDB& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData );
void write_to_db ( const dinlib::SettingsDB& 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 dinlib::SettingsDB& parDB, const mchlib::TigerHash& parHash );
} //namespace din

View file

@ -1,4 +1,4 @@
/* Copyright 2015, Michele Santullo
/* Copyright 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
@ -23,6 +23,8 @@
#include "dindexerConfig.h"
#include "dindexer-machinery/filesearcher.hpp"
#include "dindexer-machinery/indexer.hpp"
#include "dindexer-machinery/machinery_info.hpp"
#include "dindexer-common/common_info.hpp"
#include "dindexer-common/settings.hpp"
#include "commandline.hpp"
#include "dbbackend.hpp"
@ -196,7 +198,10 @@ namespace {
}
SetRecordData set_data {parSetName, parType};
din::write_to_db(parDBSettings, parData, set_data);
const auto app_signature = dinlib::dindexer_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());
din::write_to_db(parDBSettings, parData, set_data, signature);
return true;
}
} //unnamed namespace