Added reset action for config command

master
Vladimir Stackov 2015-02-06 13:31:09 +03:00
parent e92b316528
commit f28b2ae7c6
2 changed files with 26 additions and 11 deletions

View File

@ -542,10 +542,15 @@ void Config::reset_storable()
// TODO: Use protobuf introspection
// to fill messages in loop with default values
// without explicit declaration
SET_STORABLE( chunk, max_size, GET_STORABLE( chunk, max_size ) );
SET_STORABLE( bundle, max_payload_size, GET_STORABLE( bundle, max_payload_size ) );
SET_STORABLE( bundle, compression_method, GET_STORABLE( bundle, compression_method ) );
SET_STORABLE( lzma, compression_level, GET_STORABLE( lzma, compression_level ) );
Config defaultConfig;
SET_STORABLE( chunk, max_size, defaultConfig.GET_STORABLE( chunk, max_size ) );
SET_STORABLE( bundle, max_payload_size, defaultConfig.GET_STORABLE(
bundle, max_payload_size ) );
SET_STORABLE( bundle, compression_method, defaultConfig.GET_STORABLE(
bundle, compression_method ) );
SET_STORABLE( lzma, compression_level, defaultConfig.GET_STORABLE(
lzma, compression_level ) );
}
void Config::show()

View File

@ -156,8 +156,8 @@ invalid_option:
"Usage: %s [flags] <command [action]> [command args]\n"
" Flags: --non-encrypted|--password-file <file>\n"
" password flag should be specified twice if import/export/passwd\n"
" command specified\n"
" password flag should be specified twice if\n"
" import/export/passwd command specified\n"
" --silent (default is verbose)\n"
" --help|-h show this message\n"
" -O <Option[=Value]> (overrides runtime configuration,\n"
@ -173,13 +173,14 @@ invalid_option:
" export <source storage path> <destination storage path> -\n"
" performs export from source to destination storage\n"
" import <source storage path> <destination storage path> -\n"
" performs import from source to destination storage\n"
" performs import from source to destination storage,\n"
" for export/import storage path must be\n"
" a valid (initialized) storage\n"
" gc <storage path> - performs chunk garbage collection\n"
" passwd <storage path> - changes repo info file passphrase\n"
//" info <storage path> - shows repo information\n"
" config [show|edit|set] <storage path> - performs configuration\n"
" manipulations (default is show)\n"
" For export/import storage path must be a valid (initialized) storage\n"
" config [show|edit|set|reset] <storage path> - performs\n"
" configuration manipulations (default is show)\n"
"", zbackup_version.c_str(), *argv );
return EXIT_FAILURE;
}
@ -337,7 +338,7 @@ invalid_option:
{
if ( args.size() < 2 || args.size() > 3 )
{
fprintf( stderr, "Usage: %s %s [show|edit|set] <storage path>\n",
fprintf( stderr, "Usage: %s %s [show|edit|set|reset] <storage path>\n",
*argv, args[ 0 ] );
return EXIT_FAILURE;
}
@ -367,6 +368,15 @@ invalid_option:
zbb.saveExtendedStorageInfo();
}
else
if ( args.size() > 2 && strcmp( args[ fieldAction ], "reset" ) == 0 )
{
ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ),
passwords[ 0 ], true );
zbb.config.reset_storable();
zbb.config.show();
zbb.saveExtendedStorageInfo();
}
else
{
ZBackupBase zbb( ZBackupBase::deriveStorageDirFromBackupsFile( args[ fieldStorage ], true ),
passwords[ 0 ], true );