Data_deduplication_service
Service that will use hashes to deduplicate files
file_services::FileService Class Reference

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 ()
 

Detailed Description

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.

Member Typedef Documentation

◆ indexType

Constructor & Destructor Documentation

◆ FileService()

file_services::FileService::FileService ( )
default

Member Function Documentation

◆ checkConnection()

bool file_services::FileService::checkConnection ( )
inline

◆ clearSegments()

int file_services::FileService::clearSegments ( )
+ Here is the call graph for this function:

◆ dbDrop()

int file_services::FileService::dbDrop ( std::string_view  dbName)
inline
+ Here is the caller graph for this function:

◆ dbLoad() [1/2]

template<dbUsageStrategy str>
int file_services::FileService::dbLoad ( db_services::myConnString cStr)
Template Parameters
dbUsageStrategy
Parameters
cStr"dbLoad(std::string_view dbName, std::string_view configurationFile = db_services::cfileName) "dbLoad()"
+ Here is the call graph for this function:

◆ dbLoad() [2/2]

template<dbUsageStrategy str>
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.

Template Parameters
dbUsageStrategy
hash
Parameters
dbName
configurationFile
+ Here is the call graph for this function:

◆ deleteDirectory()

int file_services::FileService::deleteDirectory ( std::string_view  dirPath)

Deletes database entry and data for directory

Parameters
dirPath
+ Here is the call graph for this function:

◆ deleteFile()

int file_services::FileService::deleteFile ( std::string_view  filePath)

Deletes file entry and data from database

Parameters
filePath
+ Here is the call graph for this function:

◆ disconnect()

void file_services::FileService::disconnect ( )
inline

◆ executeInTransaction() [1/2]

template<typename ResType1 , typename ... Args>
tl::expected<ResType1, int> file_services::FileService::executeInTransaction ( const std::function< ResType1(db_services::trasnactionType &, Args ...)> &  call,
Args &&...  args 
)
inline

Wrapper for assoctiated dbManger member function

See also
dbManager::executeInTransaction(const std::function< ResultType (trasnactionType &, Args ...)> & call,Args &&... args ) "executeInTransaction()"

◆ executeInTransaction() [2/2]

template<typename ResType1 , typename ... Args>
tl::expected<ResType1, int> file_services::FileService::executeInTransaction ( ResType1(*)(db_services::trasnactionType &, Args ...)  call,
Args &&...  args 
)
inline

Wrapper for associated dbManger member function

See also
executeInTransaction()
+ Here is the caller graph for this function:

◆ getCoefficient()

tl::expected< double, int > file_services::FileService::getCoefficient ( )

Gets unique segments percentage

+ Here is the call graph for this function:

◆ getDataD()

tl::expected< std::array< int, 5 >, int > file_services::FileService::getDataD ( )

Gets database sizes statistics

+ Here is the call graph for this function:

◆ insertDirEntry()

int file_services::FileService::insertDirEntry ( std::string_view  dirPath)

Insert entry for directory

Parameters
dirPath
+ Here is the call graph for this function:

◆ loadDirectory()

template<rootDirectoryHandlingStrategy dir_s, dataRetrievalStrategy rr>
int file_services::FileService::loadDirectory ( std::string_view  fromDir,
std::string_view  toDir 
)

Retrieves directory from database to to_dir

Template Parameters
root_directory_str
retrievalStrategy
Parameters
fromDir
toDir
+ Here is the call graph for this function:

◆ loadFile()

template<rootDirectoryHandlingStrategy dir_s, dataRetrievalStrategy rr, bool from_load_dir>
int file_services::FileService::loadFile ( std::string_view  fromFile,
std::string_view  toFile,
indexType  fileId = paramType::EmptyParameterValue 
)

Retrieves file from database to to_file

Template Parameters
dir_s
retrievalStrategy
Parameters
fromFile
toFile
+ Here is the call graph for this function:

◆ processDirectory()

template<dataInsetionStrategy strategy>
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

Template Parameters
data_insertion_str
Parameters
dirPath
segmentSize
hash
+ Here is the call graph for this function:

◆ processFile()

template<dataInsetionStrategy strategy, bool existence_checks>
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.

Template Parameters
data_insertion_str
existence_checks
Parameters
filePath
segmentSize
hash
+ Here is the call graph for this function:

The documentation for this class was generated from the following files: