diff --git a/CONTRIBUTORS b/CONTRIBUTORS index dc928ec..b088c49 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -4,12 +4,15 @@ to the ZBackup. Original design and implementation: Konstantin Isakov +Core maintainers: + Konstantin Isakov + Vladimir Stackov + Code contributions: Benjamin Koch - Vladimir Stackov Gleb Golubitsky - ikatson - Eugene Agafonov + Igor Katson + Eugene Agafonov Antonia Stevens Feel free to add yourself to this list in your pull-request. diff --git a/backup_collector.cc b/backup_collector.cc index bc935db..51472a9 100644 --- a/backup_collector.cc +++ b/backup_collector.cc @@ -25,7 +25,7 @@ private: int indexModifiedBundles, indexKeptBundles, indexRemovedBundles; bool indexModified; vector< string > filesToUnlink; - + public: string bundlesPath; bool verbose; @@ -123,12 +123,11 @@ public: } ZCollector::ZCollector( string const & storageDir, string const & password, - size_t threads, size_t cacheSize ): - ZBackupBase( storageDir, password ), + Config & inConfig ): + ZBackupBase( storageDir, password, inConfig ), chunkStorageReader( storageInfo, encryptionkey, chunkIndex, getBundlesPath(), - cacheSize ) + config.runtime.cacheSize ) { - this->threads = threads; } void ZCollector::gc() @@ -136,7 +135,7 @@ void ZCollector::gc() ChunkIndex chunkReindex( encryptionkey, tmpMgr, getIndexPath(), true ); ChunkStorage::Writer chunkStorageWriter( storageInfo, encryptionkey, tmpMgr, chunkReindex, - getBundlesPath(), getIndexPath(), threads ); + getBundlesPath(), getIndexPath(), config.runtime.threads ); string fileName; string backupsPath = getBackupsPath(); diff --git a/backup_collector.hh b/backup_collector.hh index 8ca060c..5f8a3b7 100644 --- a/backup_collector.hh +++ b/backup_collector.hh @@ -10,11 +10,10 @@ class ZCollector : public ZBackupBase { ChunkStorage::Reader chunkStorageReader; - size_t threads; public: ZCollector( std::string const & storageDir, std::string const & password, - size_t threads, size_t cacheSize ); + Config & inConfig ); void gc(); }; diff --git a/config.cc b/config.cc index c0bd841..c792ccf 100644 --- a/config.cc +++ b/config.cc @@ -1,75 +1,263 @@ // Copyright (c) 2012-2014 Konstantin Isakov and ZBackup contributors, see CONTRIBUTORS // Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE +#include #include "config.hh" +#include "ex.hh" #include "debug.hh" +#include "utils.hh" -/* Keyword tokens. */ +#define VALID_SUFFIXES "Valid suffixes:\n" \ + "B - multiply by 1 (bytes)\n" \ + "KiB - multiply by 1024 (kibibytes)\n" \ + "MiB - multiply by 1024*1024 (mebibytes)\n" \ + "GiB - multiply by 1024*1024*1024 (gibibytes)\n" \ + "KB - multiply by 1000 (kilobytes)\n" \ + "MB - multiply by 1000*1000 (megabytes)\n" \ + "GB - multiply by 1000*1000*1000 (gigabytes)\n" \ -typedef enum -{ - oBadOption, +DEF_EX_STR( exInvalidThreadsValue, "Invalid threads value specified:", std::exception ) - oChunk_max_size, - oBundle_max_payload_size, - oBundle_compression_method, - - oDeprecated, oUnsupported -} OpCodes; +namespace ConfigHelper { +Config defaultConfig; /* Textual representations of the tokens. */ static struct { const char * name; - OpCodes opcode; + const Config::OpCodes opcode; + const Config::OptionType type; const char * description; + const string defaultValue; } keywords[] = { + // Storable options { "chunk.max_size", - oChunk_max_size, + Config::oChunk_max_size, + Config::Storable, "Maximum chunk size used when storing chunks\n" - "Directly affects deduplication ratio" + "Affects deduplication ratio directly" }, { "bundle.max_payload_size", - oBundle_max_payload_size, + Config::oBundle_max_payload_size, + Config::Storable, "Maximum number of bytes a bundle can hold. Only real chunk bytes are\n" "counted, not metadata. Any bundle should be able to contain at least\n" "one arbitrary single chunk, so this should not be smaller than\n" "chunk.max_size" }, { "bundle.compression_method", - oBundle_compression_method, + Config::oBundle_compression_method, + Config::Storable, "Compression method for new bundles" }, + + // Shortcuts for storable options { "compression", - oBundle_compression_method, + Config::oBundle_compression_method, + Config::Storable, "Shortcut for bundle.compression_method" }, - { NULL, oBadOption } + // Runtime options + { + "threads", + Config::oRuntime_threads, + Config::Runtime, + "Maximum number of compressor threads to use in backup process\n" + "Default is %s on your system", + Utils::numberToString( defaultConfig.runtime.threads ) + }, + { + "cache-size", + Config::oRuntime_cacheSize, + Config::Runtime, + "Cache size to use in restore process\n" + "Affects restore process speed directly\n" + VALID_SUFFIXES + "Default is %sMiB", + Utils::numberToString( defaultConfig.runtime.cacheSize / 1024 / 1024 ) + }, + + { NULL, Config::oBadOption, Config::None } }; -bool Config::parseOption( const char * option ) -{ - dPrintf( "Parsing option \"%s\"...\n", option ); - return true; } -void Config::showHelp() +Config::OpCodes Config::parseToken( const char * option, const OptionType type ) { + for ( u_int i = 0; ConfigHelper::keywords[ i ].name; i++ ) + { + if ( strcasecmp( option, ConfigHelper::keywords[ i ].name ) == 0 ) + { + if ( ConfigHelper::keywords[ i ].type != type ) + { + fprintf( stderr, "Invalid option type specified for %s\n", option ); + break; + } + + return ConfigHelper::keywords[ i ].opcode; + } + } + + return Config::oBadOption; +} + +bool Config::parseOption( const char * option, const OptionType type ) +{ + string prefix; + if ( type == Runtime ) + prefix.assign( "runtime" ); + else + if ( type == Storable ) + prefix.assign( "storable" ); + dPrintf( "Parsing %s option \"%s\"...\n", prefix.c_str(), option ); + + bool hasValue = false; + size_t optionLength = strlen( option ); + char optionName[ optionLength ], optionValue[ optionLength ]; + + if ( sscanf( option, "%[^=]=%s", optionName, optionValue ) == 2 ) + { + dPrintf( "%s option name: %s, value: %s\n", prefix.c_str(), + optionName, optionValue ); + hasValue = true; + } + else + dPrintf( "%s option name: %s\n", prefix.c_str(), option ); + + int opcode = parseToken( hasValue ? optionName : option, type ); + + size_t sizeValue; + char suffix[ 16 ]; + int n; + unsigned int scale, scaleBase = 1; + + switch ( opcode ) + { + case oRuntime_threads: + if ( !hasValue ) + return false; + + sizeValue = runtime.threads; + if ( sscanf( optionValue, "%zu %n", &sizeValue, &n ) != 1 || + optionValue[ n ] || sizeValue < 1 ) + throw exInvalidThreadsValue( optionValue ); + runtime.threads = sizeValue; + + dPrintf( "runtime[threads]: %zu\n", runtime.threads ); + + return true; + /* NOTREACHED */ + break; + + case oRuntime_cacheSize: + if ( !hasValue ) + return false; + + sizeValue = runtime.cacheSize; + if ( sscanf( optionValue, "%zu %15s %n", + &sizeValue, suffix, &n ) == 2 && !optionValue[ n ] ) + { + // Check the suffix + for ( char * c = suffix; *c; ++c ) + *c = tolower( *c ); + + if ( strcmp( suffix, "b" ) == 0 ) + { + scale = 1; + } + else + if ( strcmp( suffix, "kib" ) == 0 ) + { + scaleBase = 1024; + scale = scaleBase; + } + else + if ( strcmp( suffix, "mib" ) == 0 ) + { + scaleBase = 1024; + scale = scaleBase * scaleBase; + } + else + if ( strcmp( suffix, "gib" ) == 0 ) + { + scaleBase = 1024; + scale = scaleBase * scaleBase * scaleBase; + } + else + if ( strcmp( suffix, "kb" ) == 0 ) + { + scaleBase = 1000; + scale = scaleBase; + } + else + if ( strcmp( suffix, "mb" ) == 0 ) + { + scaleBase = 1000; + scale = scaleBase * scaleBase; + } + else + if ( strcmp( suffix, "gb" ) == 0 ) + { + scaleBase = 1000; + scale = scaleBase * scaleBase * scaleBase; + } + else + { + // SI or IEC + fprintf( stderr, "Invalid suffix specified in cache size (%s): %s. " + VALID_SUFFIXES, + optionValue, suffix ); + return false; + } + runtime.cacheSize = sizeValue * scale; + + dPrintf( "runtime[cacheSize]: %zu\n", runtime.cacheSize ); + + return true; + } + return false; + /* NOTREACHED */ + break; + + case oBadOption: + default: + return false; + /* NOTREACHED */ + break; + } + + /* NOTREACHED */ + return false; +} + +void Config::showHelp( const OptionType type ) +{ + string prefix; + if ( type == Runtime ) + prefix.assign( "runtime" ); + else + if ( type == Storable ) + prefix.assign( "storable" ); fprintf( stderr, -"Available options overview:\n\n" +"Available %s options overview:\n\n" "== help ==\n" "shows this message\n" -""); +"", prefix.c_str() ); - u_int i; - for ( i = 0; keywords[ i ].name; i++ ) + for ( u_int i = 0; ConfigHelper::keywords[ i ].name; i++ ) { - fprintf( stderr, "\n== %s ==\n%s\n", keywords[ i ].name, keywords[ i ].description ); + if ( ConfigHelper::keywords[ i ].type != type ) + continue; + + fprintf( stderr, "\n== %s ==\n", ConfigHelper::keywords[ i ].name ); + fprintf( stderr, ConfigHelper::keywords[ i ].description, + ConfigHelper::keywords[ i ].defaultValue.c_str() ); + fprintf( stderr, "\n" ); } } diff --git a/config.hh b/config.hh index c90cfcb..ad387c8 100644 --- a/config.hh +++ b/config.hh @@ -5,30 +5,65 @@ #define CONFIG_HH_INCLUDED__ #include -#include #include #include "zbackup.pb.h" +#include "mt.hh" using std::string; -using std::vector; class Config { public: - typedef vector< string > Options; + struct RuntimeConfig + { + size_t threads; + size_t cacheSize; + + // Default runtime config + RuntimeConfig(): + threads( getNumberOfCpus() ), + cacheSize( 40 * 1024 * 1024 ) // 40 MB + { + } + }; + + RuntimeConfig runtime; + + enum OptionType + { + Runtime, + Storable, + None + }; + + /* Keyword tokens. */ + typedef enum + { + oBadOption, + + oChunk_max_size, + oBundle_max_payload_size, + oBundle_compression_method, + + oRuntime_threads, + oRuntime_cacheSize, + + oDeprecated, oUnsupported + } OpCodes; // Validator for user-supplied configuration static bool validate( const string &, const string & ); static bool parse( const string & str, google::protobuf::Message * mutable_message ); - static void showHelp(); + static void showHelp( const OptionType ); - bool parseOption( const char * option ); + OpCodes parseToken( const char * option, const OptionType ); + bool parseOption( const char * option, const OptionType ); string toString( google::protobuf::Message const & message ); private: - Options options; + ConfigInfo storableConfig; }; #endif diff --git a/file.cc b/file.cc index 72fbafb..5d4d141 100644 --- a/file.cc +++ b/file.cc @@ -6,7 +6,6 @@ #include #include #include -#include #ifdef __APPLE__ #include #else @@ -16,6 +15,7 @@ #include #include "file.hh" +#include "utils.hh" enum { @@ -124,11 +124,7 @@ void File::open( int fd, OpenMode mode ) throw( exCantOpen ) f = fdopen( fd, m ); if ( !f ) - { - std::ostringstream strFd; - strFd << fd; - throw exCantOpen( "fd#" + strFd.str() + ": " + strerror( errno ) ); - } + throw exCantOpen( "fd#" + Utils::numberToString( fd ) + ": " + strerror( errno ) ); } File::File( char const * filename, OpenMode mode ) throw( exCantOpen ): diff --git a/utils.hh b/utils.hh new file mode 100644 index 0000000..8927af5 --- /dev/null +++ b/utils.hh @@ -0,0 +1,21 @@ +// Copyright (c) 2012-2014 Konstantin Isakov and ZBackup contributors, see CONTRIBUTORS +// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE + +#ifndef UTILS_HH_INCLUDED__ +#define UTILS_HH_INCLUDED__ + +#include + +namespace Utils { + +template +std::string numberToString( T pNumber ) +{ + std::ostringstream oOStrStream; + oOStrStream << pNumber; + return oOStrStream.str(); +} + +} + +#endif diff --git a/zbackup.cc b/zbackup.cc index 01042c5..dea4b84 100644 --- a/zbackup.cc +++ b/zbackup.cc @@ -20,7 +20,6 @@ #include "encryption_key.hh" #include "ex.hh" #include "file.hh" -#include "mt.hh" #include "sha256.hh" #include "sptr.hh" #include "storage_info_file.hh" @@ -29,16 +28,17 @@ #include "bundle.hh" #include "backup_collector.hh" #include "config.hh" +#include "utils.hh" using std::vector; using std::bitset; using std::iterator; ZBackup::ZBackup( string const & storageDir, string const & password, - size_t threads ): - ZBackupBase( storageDir, password ), + Config & inConfig ): + ZBackupBase( storageDir, password, inConfig ), chunkStorageWriter( storageInfo, encryptionkey, tmpMgr, chunkIndex, - getBundlesPath(), getIndexPath(), threads ) + getBundlesPath(), getIndexPath(), config.runtime.threads ) { } @@ -141,10 +141,10 @@ void ZBackup::backupFromStdin( string const & outputFileName ) } ZRestore::ZRestore( string const & storageDir, string const & password, - size_t cacheSize ): - ZBackupBase( storageDir, password ), + Config & inConfig ): + ZBackupBase( storageDir, password, inConfig ), chunkStorageReader( storageInfo, encryptionkey, chunkIndex, getBundlesPath(), - cacheSize ) + config.runtime.cacheSize ) { } @@ -325,18 +325,12 @@ DEF_EX( exSpecifyTwoKeys, "Specify password flag (--non-encrypted or --password- " for import/export/passwd operation twice (first for source and second for destination)", std::exception ) DEF_EX( exNonEncryptedWithKey, "--non-encrypted and --password-file are incompatible", std::exception ) DEF_EX( exSpecifyEncryptionOptions, "Specify either --password-file or --non-encrypted", std::exception ) -DEF_EX_STR( exInvalidThreadsValue, "Invalid threads value specified:", std::exception ) int main( int argc, char *argv[] ) { try { - size_t const defaultThreads = getNumberOfCpus(); - size_t threads = defaultThreads; - size_t const defaultCacheSizeMb = 40; - size_t cacheSizeMb = defaultCacheSizeMb; bool printHelp = false; - bool forcedCompressionMethod = false; vector< char const * > args; vector< string > passwords; bitset< BackupExchanger::Flags > exchange; @@ -344,6 +338,10 @@ int main( int argc, char *argv[] ) for( int x = 1; x < argc; ++x ) { + char const * option; + string deprecated; + Config::OptionType optionType = Config::Runtime; + if ( strcmp( argv[ x ], "--password-file" ) == 0 && x + 1 < argc ) { // Read the password @@ -397,43 +395,33 @@ int main( int argc, char *argv[] ) else if ( strcmp( argv[ x ], "--threads" ) == 0 && x + 1 < argc ) { - int n; - if ( sscanf( argv[ x + 1 ], "%zu %n", &threads, &n ) != 1 || - argv[ x + 1 ][ n ] || threads < 1 ) - throw exInvalidThreadsValue( argv[ x + 1 ] ); - ++x; + fprintf( stderr, "--threads is deprecated, use -O threads instead\n" ); + deprecated.assign( argv[ x ] + 2 ); + deprecated.append( "=" ); + deprecated.append( argv[ x + 1 ] ); + option = deprecated.c_str(); + if ( option ) + goto parse_option; } else if ( strcmp( argv[ x ], "--cache-size" ) == 0 && x + 1 < argc ) { + fprintf( stderr, "--cache-size is deprecated, use -O cache-size instead\n" ); + size_t cacheSizeMb; char suffix[ 16 ]; int n; if ( sscanf( argv[ x + 1 ], "%zu %15s %n", - &cacheSizeMb, suffix, &n ) == 2 && !argv[ x + 1 ][ n ] ) - { - // Check the suffix - for ( char * c = suffix; *c; ++c ) - *c = tolower( *c ); + &cacheSizeMb, suffix, &n ) == 2 && !argv[ x + 1][ n ] ) - if ( strcmp( suffix, "mb" ) != 0 ) - { - fprintf( stderr, "Invalid suffix specified in cache size: %s. " - "The only supported suffix is 'mb' for megabytes\n", - argv[ x + 1 ] ); - return EXIT_FAILURE; - } - - ++x; - } - else - { - fprintf( stderr, "Invalid cache size value specified: %s. " - "Must be a number with the 'mb' suffix, e.g. '100mb'\n", - argv[ x + 1 ] ); - return EXIT_FAILURE; - } + deprecated.assign( argv[ x ] + 2 ); + deprecated.append( "=" ); + deprecated.append( Utils::numberToString( cacheSizeMb ) ); + deprecated.append( "MiB" ); + option = deprecated.c_str(); + if ( option ) + goto parse_option; } - else +/* else if ( strcmp( argv[ x ], "--compression" ) == 0 && x + 1 < argc ) { forcedCompressionMethod = true; @@ -473,26 +461,34 @@ int main( int argc, char *argv[] ) argv[ x ] ); return EXIT_FAILURE; } - } + }*/ else if ( strcmp( argv[ x ], "--help" ) == 0 || strcmp( argv[ x ], "-h" ) == 0 ) { printHelp = true; } else - if ( strcmp( argv[ x ], "-o" ) == 0 && x + 1 < argc ) + if ( ( strcmp( argv[ x ], "-o" ) == 0 || strcmp( argv[ x ], "-O" ) == 0 ) + && x + 1 < argc ) { - char const * option = argv[ x + 1 ]; + option = argv[ x + 1 ]; if ( option ) { + if ( strcmp( argv[ x ], "-O" ) == 0 ) + optionType = Config::Runtime; + else + if ( strcmp( argv[ x ], "-o" ) == 0 ) + optionType = Config::Storable; + if ( strcmp( option, "help" ) == 0 ) { - Config::showHelp(); + Config::showHelp( optionType ); return EXIT_SUCCESS; } else { - if ( !config.parseOption( option ) ) +parse_option: + if ( !config.parseOption( option, optionType ) ) goto invalid_option; } } @@ -523,14 +519,15 @@ invalid_option: " password flag should be specified twice if import/export/passwd\n" " command specified\n" " --silent (default is verbose)\n" -" --threads (default is %zu on your system)\n" -" --cache-size MB (default is %zu)\n" -" --exchange (can be\n" -" specified multiple times)\n" +" --exchange (can be specified\n" +" multiple times, valid only for import/export commands)\n" " --help|-h show this message\n" -" -o (overrides repository configuration,\n" +" -O (overrides runtime configuration,\n" " can be specified multiple times,\n" -" for detailed options overview run with -o help)\n" +" for detailed runtime options overview run with -O help)\n" +" -o (overrides storable repository\n" +" configuration, can be specified multiple times,\n" +" for detailed storable options overview run with -o help)\n" " Commands:\n" " init - initializes new storage\n" " backup - performs a backup from stdin\n" @@ -541,12 +538,11 @@ invalid_option: " performs import from source to destination storage\n" " gc - performs chunk garbage collection\n" " passwd - changes repo info file passphrase\n" -" info - shows repo information\n" +//" info - shows repo information\n" " config [show|edit|set] - performs configuration\n" " manipulations (default is show)\n" -" For export/import storage path must be valid (initialized) storage\n" -"", *argv, - defaultThreads, defaultCacheSizeMb ); +" For export/import storage path must be a valid (initialized) storage\n" +"", *argv ); return EXIT_FAILURE; } @@ -589,8 +585,8 @@ invalid_option: return EXIT_FAILURE; } ZBackup zb( ZBackup::deriveStorageDirFromBackupsFile( args[ 1 ] ), - passwords[ 0 ], threads ); - if ( !forcedCompressionMethod ) + passwords[ 0 ], config ); + //if ( !forcedCompressionMethod ) zb.useDefaultCompressionMethod(); zb.backupFromStdin( args[ 1 ] ); } @@ -605,8 +601,8 @@ invalid_option: return EXIT_FAILURE; } ZRestore zr( ZRestore::deriveStorageDirFromBackupsFile( args[ 1 ] ), - passwords[ 0 ], cacheSizeMb * 1048576 ); - if ( !forcedCompressionMethod ) + passwords[ 0 ], config ); + //if ( !forcedCompressionMethod ) zr.useDefaultCompressionMethod(); zr.restoreToStdin( args[ 1 ] ); } @@ -656,8 +652,8 @@ invalid_option: *argv, args[ 0 ] ); return EXIT_FAILURE; } - ZCollector zr( args[ 1 ], passwords[ 0 ], threads, cacheSizeMb * 1048576 ); - zr.gc(); + ZCollector zc( args[ 1 ], passwords[ 0 ], config ); + zc.gc(); } else if ( strcmp( args[ 0 ], "passwd" ) == 0 ) @@ -703,10 +699,9 @@ invalid_option: else if ( strcmp( args[ 0 ], "config" ) == 0 ) { - // Show repo info if ( args.size() < 2 || args.size() > 3 ) { - fprintf( stderr, "Usage: %s %s [show|edit] \n", + fprintf( stderr, "Usage: %s %s [show|edit|set] \n", *argv, args[ 0 ] ); return EXIT_FAILURE; } diff --git a/zbackup.hh b/zbackup.hh index c48b219..979e316 100644 --- a/zbackup.hh +++ b/zbackup.hh @@ -30,7 +30,7 @@ class ZBackup: public ZBackupBase public: ZBackup( string const & storageDir, string const & password, - size_t threads ); + Config & inConfig ); /// Backs up the data from stdin void backupFromStdin( string const & outputFileName ); @@ -42,7 +42,7 @@ class ZRestore: public ZBackupBase public: ZRestore( string const & storageDir, string const & password, - size_t cacheSize ); + Config & inConfig ); /// Restores the data to stdin void restoreToStdin( string const & inputFileName ); @@ -51,11 +51,10 @@ public: class ZCollect: public ZBackupBase { ChunkStorage::Reader chunkStorageReader; - size_t threads; public: ZCollect( string const & storageDir, string const & password, - size_t threads, size_t cacheSize ); + Config & inConfig ); void gc(); }; diff --git a/zbackup_base.cc b/zbackup_base.cc index 128a634..0f60a73 100644 --- a/zbackup_base.cc +++ b/zbackup_base.cc @@ -68,6 +68,19 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password ): dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); } +ZBackupBase::ZBackupBase( string const & storageDir, string const & password, + Config & inConfig ): + Paths( storageDir ), storageInfo( loadStorageInfo() ), + encryptionkey( password, storageInfo.has_encryption_key() ? + &storageInfo.encryption_key() : 0 ), + extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ), + tmpMgr( getTmpPath() ), + chunkIndex( encryptionkey, tmpMgr, getIndexPath(), false ), + config( inConfig ) +{ + dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); +} + ZBackupBase::ZBackupBase( string const & storageDir, string const & password, bool prohibitChunkIndexLoading ): Paths( storageDir ), storageInfo( loadStorageInfo() ), @@ -80,6 +93,19 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password, dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); } +ZBackupBase::ZBackupBase( string const & storageDir, string const & password, + Config & inConfig, bool prohibitChunkIndexLoading ): + Paths( storageDir ), storageInfo( loadStorageInfo() ), + encryptionkey( password, storageInfo.has_encryption_key() ? + &storageInfo.encryption_key() : 0 ), + extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ), + tmpMgr( getTmpPath() ), + chunkIndex( encryptionkey, tmpMgr, getIndexPath(), prohibitChunkIndexLoading ), + config( inConfig ) +{ + dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); +} + StorageInfo ZBackupBase::loadStorageInfo() { StorageInfo storageInfo; diff --git a/zbackup_base.hh b/zbackup_base.hh index cc6a34a..eae1d1e 100644 --- a/zbackup_base.hh +++ b/zbackup_base.hh @@ -43,7 +43,11 @@ public: /// Opens the storage ZBackupBase( std::string const & storageDir, std::string const & password ); - ZBackupBase( std::string const & storageDir, std::string const & password, bool prohibitChunkIndexLoading ); + ZBackupBase( std::string const & storageDir, std::string const & password, Config & inConfig ); + ZBackupBase( std::string const & storageDir, std::string const & password, + bool prohibitChunkIndexLoading ); + ZBackupBase( std::string const & storageDir, std::string const & password, Config & inConfig, + bool prohibitChunkIndexLoading ); /// Creates new storage static void initStorage( std::string const & storageDir, std::string const & password,