Data_deduplication_service
Service that will use hashes to deduplicate files
|
this class handles file/directory management and uses dbManager to perform calls More...
#include <FileService.h>
Public Types | |
using | indexType = db_services::indexType |
Public Member Functions | |
FileService ()=default | |
template<dbUsageStrategy dbUsageStrategy = use> | |
int | dbLoad (std::string_view dbName, std::string_view configurationFile=db_services::cfileName) |
template<dbUsageStrategy dbUsageStrategy = use> | |
int | dbLoad (db_services::myConnString &cStr) |
int | dbDrop (std::string_view dbName) |
template<dataInsetionStrategy data_insertion_str = PreserveOld> | |
int | processDirectory (std::string_view dirPath, size_t segmentSize, const hash_function &hash=SHA_256) |
template<dataInsetionStrategy data_insertion_str = PreserveOld, bool existence_checks = true> | |
int | processFile (std::string_view filePath, size_t segmentSize, const hash_function &hash=SHA_256) |
int | insertDirEntry (std::string_view dirPath) |
tl::expected< double, int > | getCoefficient () |
tl::expected< std::array< int, 5 >, int > | getDataD () |
template<rootDirectoryHandlingStrategy root_directory_str = NoCreateMain, dataRetrievalStrategy retrievalStrategy = Persist> | |
int | loadDirectory (std::string_view fromDir, std::string_view toDir) |
template<rootDirectoryHandlingStrategy dir_s = NoCreateMain, dataRetrievalStrategy retrievalStrategy = Persist, bool from_load_dir = false> | |
int | loadFile (std::string_view fromFile, std::string_view toFile, indexType fileId=paramType::EmptyParameterValue) |
int | deleteFile (std::string_view filePath) |
int | deleteDirectory (std::string_view dirPath) |
bool | checkConnection () |
int | clearSegments () |
template<typename ResType1 , typename ... Args> | |
tl::expected< ResType1, int > | executeInTransaction (ResType1(*call)(db_services::trasnactionType &, Args ...), Args &&... args) |
template<typename ResType1 , typename ... Args> | |
tl::expected< ResType1, int > | executeInTransaction (const std::function< ResType1(db_services::trasnactionType &, Args ...)> &call, Args &&... args) |
void | disconnect () |
this class handles file/directory management and uses dbManager to perform calls
This class have comfortable wrappers for most db_services::dbManager functions
Some external helepr functions can be found here.
|
default |
|
inline |
int file_services::FileService::clearSegments | ( | ) |
|
inline |
int file_services::FileService::dbLoad | ( | db_services::myConnString & | cStr | ) |
dbUsageStrategy |
cStr | "dbLoad(std::string_view dbName, std::string_view configurationFile = db_services::cfileName) "dbLoad()" |
int file_services::FileService::dbLoad | ( | std::string_view | dbName, |
std::string_view | configurationFile = db_services::cfileName |
||
) |
This function handles database open/create action If db_usage_str==create this function will create new database othervice it'll try to open existing database.
dbUsageStrategy | |
hash |
dbName | |
configurationFile |
int file_services::FileService::deleteDirectory | ( | std::string_view | dirPath | ) |
Deletes database entry and data for directory
dirPath |
int file_services::FileService::deleteFile | ( | std::string_view | filePath | ) |
Deletes file entry and data from database
filePath |
|
inline |
|
inline |
Wrapper for assoctiated dbManger member function
|
inline |
Wrapper for associated dbManger member function
tl::expected< double, int > file_services::FileService::getCoefficient | ( | ) |
Gets unique segments percentage
tl::expected< std::array< int, 5 >, int > file_services::FileService::getDataD | ( | ) |
Gets database sizes statistics
int file_services::FileService::insertDirEntry | ( | std::string_view | dirPath | ) |
Insert entry for directory
dirPath |
int file_services::FileService::loadDirectory | ( | std::string_view | fromDir, |
std::string_view | toDir | ||
) |
Retrieves directory from database to to_dir
root_directory_str | |
retrievalStrategy |
fromDir | |
toDir |
int file_services::FileService::loadFile | ( | std::string_view | fromFile, |
std::string_view | toFile, | ||
indexType | fileId = paramType::EmptyParameterValue |
||
) |
Retrieves file from database to to_file
dir_s | |
retrievalStrategy |
fromFile | |
toFile |
int file_services::FileService::processDirectory | ( | std::string_view | dirPath, |
size_t | segmentSize, | ||
const hash_function & | hash = SHA_256 |
||
) |
Processes all files in the given directory runs processFile() for each file
data_insertion_str |
dirPath | |
segmentSize | |
hash |
int file_services::FileService::processFile | ( | std::string_view | filePath, |
size_t | segmentSize, | ||
const hash_function & | hash = SHA_256 |
||
) |
Creates entry for file in database.
Load file segments into temp table.
Upsets segment entiries
Add file data.
data_insertion_str | |
existence_checks |
filePath | |
segmentSize | |
hash |