From 2f736764acb4407d923122ab06cd490bf73b5b01 Mon Sep 17 00:00:00 2001 From: Vladimir Stackov Date: Sun, 18 Jan 2015 03:42:52 +0300 Subject: [PATCH] Storable options is almost done --- backup_collector.cc | 4 +- backup_collector.hh | 2 +- backup_exchanger.hh | 1 - bundle.cc | 2 +- compression.cc | 2 +- compression.hh | 2 +- config.cc | 88 +++++++++++++++++++++++- config.hh | 5 ++ zbackup.cc | 164 ++++++++++++++------------------------------ zbackup.hh | 27 +++----- zbackup_base.cc | 32 +++++---- zbackup_base.hh | 6 +- 12 files changed, 175 insertions(+), 160 deletions(-) diff --git a/backup_collector.cc b/backup_collector.cc index 51472a9..f1d358d 100644 --- a/backup_collector.cc +++ b/backup_collector.cc @@ -123,8 +123,8 @@ class BundleCollector: public IndexProcessor } ZCollector::ZCollector( string const & storageDir, string const & password, - Config & inConfig ): - ZBackupBase( storageDir, password, inConfig ), + Config & configIn ): + ZBackupBase( storageDir, password, configIn ), chunkStorageReader( storageInfo, encryptionkey, chunkIndex, getBundlesPath(), config.runtime.cacheSize ) { diff --git a/backup_collector.hh b/backup_collector.hh index 5f8a3b7..e1716ff 100644 --- a/backup_collector.hh +++ b/backup_collector.hh @@ -13,7 +13,7 @@ class ZCollector : public ZBackupBase public: ZCollector( std::string const & storageDir, std::string const & password, - Config & inConfig ); + Config & configIn ); void gc(); }; diff --git a/backup_exchanger.hh b/backup_exchanger.hh index 67db691..afface2 100644 --- a/backup_exchanger.hh +++ b/backup_exchanger.hh @@ -6,7 +6,6 @@ #include #include -#include "sptr.hh" #include "tmp_mgr.hh" namespace BackupExchanger { diff --git a/bundle.cc b/bundle.cc index 8ca2ae3..1248038 100644 --- a/bundle.cc +++ b/bundle.cc @@ -98,7 +98,7 @@ void Creator::write( std::string const & fileName, EncryptionKey const & key ) BundleFileHeader header; - const_sptr compression = Compression::CompressionMethod::defaultCompression; + const_sptr compression = Compression::CompressionMethod::selectedCompression; header.set_compression_method( compression->getName() ); // The old code only support lzma, so we will bump up the version, if we're diff --git a/compression.cc b/compression.cc index ef6e9ad..f4cf934 100644 --- a/compression.cc +++ b/compression.cc @@ -596,7 +596,7 @@ static const_sptr const compressions[] = { NULL }; -const_sptr CompressionMethod::defaultCompression = compressions[0]; +const_sptr CompressionMethod::selectedCompression = compressions[0]; const_sptr CompressionMethod::findCompression( const std::string& name, bool optional ) { diff --git a/compression.hh b/compression.hh index aabf1de..66718b4 100644 --- a/compression.hh +++ b/compression.hh @@ -60,7 +60,7 @@ public: static const_sptr findCompression( const std::string& name, bool optional = false ); - static const_sptr defaultCompression; + static const_sptr selectedCompression; class iterator { diff --git a/config.cc b/config.cc index c792ccf..71c8fc1 100644 --- a/config.cc +++ b/config.cc @@ -6,6 +6,7 @@ #include "ex.hh" #include "debug.hh" #include "utils.hh" +#include "compression.hh" #define VALID_SUFFIXES "Valid suffixes:\n" \ "B - multiply by 1 (bytes)\n" \ @@ -46,7 +47,8 @@ static struct "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" }, + "chunk.max_size" + }, { "bundle.compression_method", Config::oBundle_compression_method, @@ -81,6 +83,18 @@ static struct "Default is %sMiB", Utils::numberToString( defaultConfig.runtime.cacheSize / 1024 / 1024 ) }, + { + "exchange", + Config::oRuntime_exchange, + Config::Runtime, + "Data to exchange between repositories in import/export process\n" + "Can be specified multiple times\n" + "Valid values:\n" + "backups - exchange backup instructions (files in backups/ directory)\n" + "bundles - exchange bundles with data (files in bunles/ directory)\n" + "index - exchange indicies of chunks (files in index/ directory)\n" + "No default value, you should specify it explicitly" + }, { NULL, Config::oBadOption, Config::None } }; @@ -138,6 +152,48 @@ bool Config::parseOption( const char * option, const OptionType type ) switch ( opcode ) { + case oBundle_compression_method: + if ( !hasValue ) + return false; + + if ( strcmp( optionValue, "lzma" ) == 0 ) + { + const_sptr< Compression::CompressionMethod > lzma = + Compression::CompressionMethod::findCompression( "lzma" ); + if ( !lzma ) + { + fprintf( stderr, "zbackup is compiled without LZMA support, but the code " + "would support it. If you install liblzma (including development files) " + "and recompile zbackup, you can use LZMA.\n" ); + return false; + } + Compression::CompressionMethod::selectedCompression = lzma; + } + else + if ( strcmp( optionValue, "lzo" ) == 0 ) + { + const_sptr< Compression::CompressionMethod > lzo = + Compression::CompressionMethod::findCompression( "lzo1x_1" ); + if ( !lzo ) + { + fprintf( stderr, "zbackup is compiled without LZO support, but the code " + "would support it. If you install liblzo2 (including development files) " + "and recompile zbackup, you can use LZO.\n" ); + return false; + } + Compression::CompressionMethod::selectedCompression = lzo; + } + else + { + fprintf( stderr, "zbackup doesn't support compression method '%s'. You may need a newer version.\n", + optionValue ); + return false; + } + + return true; + /* NOTREACHED */ + break; + case oRuntime_threads: if ( !hasValue ) return false; @@ -148,7 +204,7 @@ bool Config::parseOption( const char * option, const OptionType type ) throw exInvalidThreadsValue( optionValue ); runtime.threads = sizeValue; - dPrintf( "runtime[threads]: %zu\n", runtime.threads ); + dPrintf( "runtime[threads] = %zu\n", runtime.threads ); return true; /* NOTREACHED */ @@ -216,7 +272,7 @@ bool Config::parseOption( const char * option, const OptionType type ) } runtime.cacheSize = sizeValue * scale; - dPrintf( "runtime[cacheSize]: %zu\n", runtime.cacheSize ); + dPrintf( "runtime[cacheSize] = %zu\n", runtime.cacheSize ); return true; } @@ -224,6 +280,32 @@ bool Config::parseOption( const char * option, const OptionType type ) /* NOTREACHED */ break; + case oRuntime_exchange: + if ( !hasValue ) + return false; + + if ( strcmp( optionValue, "backups" ) == 0 ) + runtime.exchange.set( BackupExchanger::backups ); + else + if ( strcmp( optionValue, "bundles" ) == 0 ) + runtime.exchange.set( BackupExchanger::bundles ); + else + if ( strcmp( optionValue, "index" ) == 0 ) + runtime.exchange.set( BackupExchanger::index ); + else + { + fprintf( stderr, "Invalid exchange value specified: %s\n" + "Must be one of the following: backups, bundles, index\n", + optionValue ); + return false; + } + + dPrintf( "runtime[exchange] = %s\n", runtime.exchange.to_string().c_str() ); + + return true; + /* NOTREACHED */ + break; + case oBadOption: default: return false; diff --git a/config.hh b/config.hh index ad387c8..ff7cc26 100644 --- a/config.hh +++ b/config.hh @@ -5,11 +5,14 @@ #define CONFIG_HH_INCLUDED__ #include +#include #include #include "zbackup.pb.h" #include "mt.hh" +#include "backup_exchanger.hh" using std::string; +using std::bitset; class Config { @@ -18,6 +21,7 @@ public: { size_t threads; size_t cacheSize; + bitset< BackupExchanger::Flags > exchange; // Default runtime config RuntimeConfig(): @@ -47,6 +51,7 @@ public: oRuntime_threads, oRuntime_cacheSize, + oRuntime_exchange, oDeprecated, oUnsupported } OpCodes; diff --git a/zbackup.cc b/zbackup.cc index dea4b84..a3486c1 100644 --- a/zbackup.cc +++ b/zbackup.cc @@ -1,31 +1,12 @@ // 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 -#include -#include -#include -#include -#include -#include -#include - +#include "zbackup.hh" #include "backup_creator.hh" #include "backup_file.hh" #include "backup_restorer.hh" -#include "compression.hh" #include "debug.hh" -#include "dir.hh" -#include "encryption_key.hh" -#include "ex.hh" -#include "file.hh" #include "sha256.hh" -#include "sptr.hh" -#include "storage_info_file.hh" -#include "zbackup.hh" -#include "index_file.hh" -#include "bundle.hh" #include "backup_collector.hh" #include "config.hh" #include "utils.hh" @@ -35,8 +16,8 @@ using std::bitset; using std::iterator; ZBackup::ZBackup( string const & storageDir, string const & password, - Config & inConfig ): - ZBackupBase( storageDir, password, inConfig ), + Config & configIn ): + ZBackupBase( storageDir, password, configIn ), chunkStorageWriter( storageInfo, encryptionkey, tmpMgr, chunkIndex, getBundlesPath(), getIndexPath(), config.runtime.threads ) { @@ -141,8 +122,8 @@ void ZBackup::backupFromStdin( string const & outputFileName ) } ZRestore::ZRestore( string const & storageDir, string const & password, - Config & inConfig ): - ZBackupBase( storageDir, password, inConfig ), + Config & configIn ): + ZBackupBase( storageDir, password, configIn ), chunkStorageReader( storageInfo, encryptionkey, chunkIndex, getBundlesPath(), config.runtime.cacheSize ) { @@ -181,18 +162,19 @@ void ZRestore::restoreToStdin( string const & inputFileName ) } ZExchange::ZExchange( string const & srcStorageDir, string const & srcPassword, - string const & dstStorageDir, string const & dstPassword ): - srcZBackupBase( srcStorageDir, srcPassword, true ), - dstZBackupBase( dstStorageDir, dstPassword, true ) + string const & dstStorageDir, string const & dstPassword, + Config & configIn ): + srcZBackupBase( srcStorageDir, srcPassword, configIn, true ), + dstZBackupBase( dstStorageDir, dstPassword, configIn, true ), + config( configIn ) { } -void ZExchange::exchange( string const & srcPath, string const & dstPath, - bitset< BackupExchanger::Flags > const & exchange ) +void ZExchange::exchange() { vector< BackupExchanger::PendingExchangeRename > pendingExchangeRenames; - if ( exchange.test( BackupExchanger::bundles ) ) + if ( config.runtime.exchange.test( BackupExchanger::bundles ) ) { verbosePrintf( "Searching for bundles...\n" ); @@ -229,7 +211,7 @@ void ZExchange::exchange( string const & srcPath, string const & dstPath, verbosePrintf( "Bundle exchange completed.\n" ); } - if ( exchange.test( BackupExchanger::index ) ) + if ( config.runtime.exchange.test( BackupExchanger::index ) ) { verbosePrintf( "Searching for indicies...\n" ); vector< string > indicies = BackupExchanger::recreateDirectories( @@ -272,7 +254,7 @@ void ZExchange::exchange( string const & srcPath, string const & dstPath, verbosePrintf( "Index exchange completed.\n" ); } - if ( exchange.test( BackupExchanger::backups ) ) + if ( config.runtime.exchange.test( BackupExchanger::backups ) ) { BackupInfo backupInfo; @@ -333,7 +315,6 @@ int main( int argc, char *argv[] ) bool printHelp = false; vector< char const * > args; vector< string > passwords; - bitset< BackupExchanger::Flags > exchange; Config config; for( int x = 1; x < argc; ++x ) @@ -363,28 +344,6 @@ int main( int argc, char *argv[] ) ++x; } else - if ( strcmp( argv[ x ], "--exchange" ) == 0 && x + 1 < argc ) - { - char const * exchangeValue = argv[ x + 1 ]; - if ( strcmp( exchangeValue, "backups" ) == 0 ) - exchange.set( BackupExchanger::backups ); - else - if ( strcmp( exchangeValue, "bundles" ) == 0 ) - exchange.set( BackupExchanger::bundles ); - else - if ( strcmp( exchangeValue, "index" ) == 0 ) - exchange.set( BackupExchanger::index ); - else - { - fprintf( stderr, "Invalid exchange value specified: %s\n" - "Must be one of the following: backups, bundles, index\n", - exchangeValue ); - return EXIT_FAILURE; - } - - ++x; - } - else if ( strcmp( argv[ x ], "--non-encrypted" ) == 0 ) { passwords.push_back( "" ); @@ -393,9 +352,20 @@ int main( int argc, char *argv[] ) if ( strcmp( argv[ x ], "--silent" ) == 0 ) verboseMode = false; else + if ( strcmp( argv[ x ], "--exchange" ) == 0 && x + 1 < argc ) + { + fprintf( stderr, "%s is deprecated, use -O exchange instead\n", argv[ x ] ); + 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 ], "--threads" ) == 0 && x + 1 < argc ) { - fprintf( stderr, "--threads is deprecated, use -O threads instead\n" ); + fprintf( stderr, "%s is deprecated, use -O threads instead\n", argv[ x ] ); deprecated.assign( argv[ x ] + 2 ); deprecated.append( "=" ); deprecated.append( argv[ x + 1 ] ); @@ -406,7 +376,7 @@ int main( int argc, char *argv[] ) else if ( strcmp( argv[ x ], "--cache-size" ) == 0 && x + 1 < argc ) { - fprintf( stderr, "--cache-size is deprecated, use -O cache-size instead\n" ); + fprintf( stderr, "%s is deprecated, use -O cache-size instead\n", argv[ x ] ); size_t cacheSizeMb; char suffix[ 16 ]; int n; @@ -421,47 +391,18 @@ int main( int argc, char *argv[] ) if ( option ) goto parse_option; } -/* else + else if ( strcmp( argv[ x ], "--compression" ) == 0 && x + 1 < argc ) { - forcedCompressionMethod = true; - - // next argument names the compression method - ++x; - if ( strcmp( argv[ x ], "lzma" ) == 0 ) - { - const_sptr lzma = - Compression::CompressionMethod::findCompression( "lzma" ); - if ( !lzma ) - { - fprintf( stderr, "zbackup is compiled without LZMA support, but the code " - "would support it. If you install liblzma (including development files) " - "and recompile zbackup, you can use LZMA.\n" ); - return EXIT_FAILURE; - } - Compression::CompressionMethod::defaultCompression = lzma; - } - else - if ( strcmp( argv[ x ], "lzo" ) == 0 ) - { - const_sptr lzo = - Compression::CompressionMethod::findCompression( "lzo1x_1" ); - if ( !lzo ) - { - fprintf( stderr, "zbackup is compiled without LZO support, but the code " - "would support it. If you install liblzo2 (including development files) " - "and recompile zbackup, you can use LZO.\n" ); - return EXIT_FAILURE; - } - Compression::CompressionMethod::defaultCompression = lzo; - } - else - { - fprintf( stderr, "zbackup doesn't support compression method '%s'. You may need a newer version.\n", - argv[ x ] ); - return EXIT_FAILURE; - } - }*/ + fprintf( stderr, "%s is deprecated, use -O bundle.compression_method instead\n", argv[ x ] ); + deprecated.assign( argv[ x ] + 2 ); + deprecated.append( "=" ); + deprecated.append( argv[ x + 1 ] ); + option = deprecated.c_str(); + optionType = Config::Storable; + if ( option ) + goto parse_option; + } else if ( strcmp( argv[ x ], "--help" ) == 0 || strcmp( argv[ x ], "-h" ) == 0 ) { @@ -519,8 +460,6 @@ int main( int argc, char *argv[] ) " password flag should be specified twice if import/export/passwd\n" " command specified\n" " --silent (default is verbose)\n" -" --exchange (can be specified\n" -" multiple times, valid only for import/export commands)\n" " --help|-h show this message\n" " -O (overrides runtime configuration,\n" " can be specified multiple times,\n" @@ -586,8 +525,6 @@ int main( int argc, char *argv[] ) } ZBackup zb( ZBackup::deriveStorageDirFromBackupsFile( args[ 1 ] ), passwords[ 0 ], config ); - //if ( !forcedCompressionMethod ) - zb.useDefaultCompressionMethod(); zb.backupFromStdin( args[ 1 ] ); } else @@ -602,8 +539,6 @@ int main( int argc, char *argv[] ) } ZRestore zr( ZRestore::deriveStorageDirFromBackupsFile( args[ 1 ] ), passwords[ 0 ], config ); - //if ( !forcedCompressionMethod ) - zr.useDefaultCompressionMethod(); zr.restoreToStdin( args[ 1 ] ); } else @@ -615,7 +550,7 @@ int main( int argc, char *argv[] ) *argv, args[ 0 ] ); return EXIT_FAILURE; } - if ( exchange.none() ) + if ( config.runtime.exchange.none() ) { fprintf( stderr, "Specify any --exchange flag\n" ); return EXIT_FAILURE; @@ -639,8 +574,9 @@ int main( int argc, char *argv[] ) ZExchange ze( ZBackupBase::deriveStorageDirFromBackupsFile( args[ src ], true ), passwords[ src - 1 ], ZBackupBase::deriveStorageDirFromBackupsFile( args[ dst ], true ), - passwords[ dst - 1 ] ); - ze.exchange( args[ src ], args[ dst ], exchange ); + passwords[ dst - 1 ], + config ); + ze.exchange(); } else if ( strcmp( args[ 0 ], "gc" ) == 0 ) @@ -706,32 +642,32 @@ int main( int argc, char *argv[] ) return EXIT_FAILURE; } - int fieldStor = 1; - int fieldAct = 2; + int fieldStorage = 1; + int fieldAction = 2; if ( args.size() == 3 ) { - fieldStor = 2; - fieldAct = 1; + fieldStorage = 2; + fieldAction = 1; } - if ( args.size() > 2 && strcmp( args[ fieldAct ], "edit" ) == 0 ) + if ( args.size() > 2 && strcmp( args[ fieldAction ], "edit" ) == 0 ) { - ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStor ], true ), + ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ), passwords[ 0 ] ); if ( zbb.editConfigInteractively() ) zbb.saveExtendedStorageInfo(); } else - if ( args.size() > 2 && strcmp( args[ fieldAct ], "set" ) == 0 ) + if ( args.size() > 2 && strcmp( args[ fieldAction ], "set" ) == 0 ) { - ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStor ], true ), + ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ), passwords[ 0 ] ); // -o ... like sysctl -w } else { - ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStor ], true ), + ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ), passwords[ 0 ] ); zbb.showConfig(); } diff --git a/zbackup.hh b/zbackup.hh index 979e316..6596a46 100644 --- a/zbackup.hh +++ b/zbackup.hh @@ -4,21 +4,8 @@ #ifndef ZBACKUP_HH_INCLUDED__ #define ZBACKUP_HH_INCLUDED__ -#include -#include -#include -#include -#include - -#include "chunk_id.hh" -#include "chunk_index.hh" #include "chunk_storage.hh" -#include "encryption_key.hh" -#include "ex.hh" -#include "tmp_mgr.hh" -#include "zbackup.pb.h" #include "zbackup_base.hh" -#include "backup_exchanger.hh" using std::string; using std::vector; @@ -30,7 +17,7 @@ class ZBackup: public ZBackupBase public: ZBackup( string const & storageDir, string const & password, - Config & inConfig ); + Config & configIn ); /// Backs up the data from stdin void backupFromStdin( string const & outputFileName ); @@ -42,7 +29,7 @@ class ZRestore: public ZBackupBase public: ZRestore( string const & storageDir, string const & password, - Config & inConfig ); + Config & configIn ); /// Restores the data to stdin void restoreToStdin( string const & inputFileName ); @@ -54,7 +41,7 @@ class ZCollect: public ZBackupBase public: ZCollect( string const & storageDir, string const & password, - Config & inConfig ); + Config & configIn ); void gc(); }; @@ -66,11 +53,13 @@ class ZExchange public: ZExchange( string const & srcStorageDir, string const & srcPassword, - string const & dstStorageDir, string const & dstPassword ); + string const & dstStorageDir, string const & dstPassword, + Config & configIn ); + + Config config; /// Exchanges the data between storages - void exchange( string const & srcFileName, string const & dstFileName, - bitset< BackupExchanger::Flags > const & exchange ); + void exchange(); }; #endif diff --git a/zbackup_base.cc b/zbackup_base.cc index 0f60a73..dbd8154 100644 --- a/zbackup_base.cc +++ b/zbackup_base.cc @@ -65,19 +65,21 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password ): tmpMgr( getTmpPath() ), chunkIndex( encryptionkey, tmpMgr, getIndexPath(), false ) { + propagateUpdate(); dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); } ZBackupBase::ZBackupBase( string const & storageDir, string const & password, - Config & inConfig ): + Config & configIn ): 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 ) + config( configIn ) { + propagateUpdate(); dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); } @@ -90,22 +92,32 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password, tmpMgr( getTmpPath() ), chunkIndex( encryptionkey, tmpMgr, getIndexPath(), prohibitChunkIndexLoading ) { + propagateUpdate(); dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); } ZBackupBase::ZBackupBase( string const & storageDir, string const & password, - Config & inConfig, bool prohibitChunkIndexLoading ): + Config & configIn, 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 ) + config( configIn ) { + propagateUpdate(); dPrintf("%s repo instantiated and initialized\n", storageDir.c_str() ); } +void ZBackupBase::propagateUpdate() +{ + const_sptr compression = + Compression::CompressionMethod::findCompression( + extendedStorageInfo.config().bundle().compression_method() ); + Compression::CompressionMethod::selectedCompression = compression; +} + StorageInfo ZBackupBase::loadStorageInfo() { StorageInfo storageInfo; @@ -134,10 +146,10 @@ void ZBackupBase::initStorage( string const & storageDir, ExtendedStorageInfo extendedStorageInfo; // TODO: Make a proper setup of initial values - storageInfo.set_chunk_max_size( 65536 ); + /*storageInfo.set_chunk_max_size( 65536 ); storageInfo.set_bundle_max_payload_size( 0x200000 ); storageInfo.set_default_compression_method( - Compression::CompressionMethod::defaultCompression->getName() ); + Compression::CompressionMethod::selectedCompression->getName() );*/ extendedStorageInfo.mutable_config()->mutable_chunk()->set_max_size( extendedStorageInfo.config().chunk().max_size() ); @@ -201,14 +213,6 @@ string ZBackupBase::deriveStorageDirFromBackupsFile( string const & return realPath.substr( 0, pos ); } -void ZBackupBase::useDefaultCompressionMethod() -{ - std::string compression_method_name = storageInfo.default_compression_method(); - const_sptr compression - = Compression::CompressionMethod::findCompression( compression_method_name ); - Compression::CompressionMethod::defaultCompression = compression; -} - void ZBackupBase::setPassword( string const & password ) { EncryptionKey::generate( password, diff --git a/zbackup_base.hh b/zbackup_base.hh index eae1d1e..ba1c170 100644 --- a/zbackup_base.hh +++ b/zbackup_base.hh @@ -43,10 +43,10 @@ public: /// Opens the storage ZBackupBase( std::string const & storageDir, std::string const & password ); - ZBackupBase( std::string const & storageDir, std::string const & password, Config & inConfig ); + ZBackupBase( std::string const & storageDir, std::string const & password, Config & configIn ); 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, Config & configIn, bool prohibitChunkIndexLoading ); /// Creates new storage @@ -57,7 +57,7 @@ public: /// storage dir or throws an exception static std::string deriveStorageDirFromBackupsFile( std::string const & backupsFile, bool allowOutside = false ); - void useDefaultCompressionMethod(); + void propagateUpdate(); void saveExtendedStorageInfo();