Skip to content

Commit

Permalink
Added sanity checks for repo migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad1mir-D committed Jan 20, 2015
1 parent 9b1eb8a commit 5be6d7f
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions zbackup_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,30 @@ ExtendedStorageInfo ZBackupBase::loadExtendedStorageInfo(
catch ( UnbufferedFile::exCantOpen & ex )
{
verbosePrintf( "Can't open extended storage info (info_extended)!\n"
"Starting repo migration.\n" );
"Attempting to start repo migration.\n" );

ExtendedStorageInfo extendedStorageInfo;
Config config( extendedStorageInfo.mutable_config() );
config.SET_STORABLE( chunk, max_size, storageInfo.chunk_max_size() );
config.SET_STORABLE( bundle, max_payload_size,
storageInfo.bundle_max_payload_size() );
config.SET_STORABLE( bundle, compression_method,
storageInfo.default_compression_method() );

ExtendedStorageInfoFile::save( getExtendedStorageInfoPath(), encryptionkey,
extendedStorageInfo );
if ( !File::exists( getExtendedStorageInfoPath() ) )
{
ExtendedStorageInfo extendedStorageInfo;
Config config( extendedStorageInfo.mutable_config() );
config.SET_STORABLE( chunk, max_size, storageInfo.chunk_max_size() );
config.SET_STORABLE( bundle, max_payload_size,
storageInfo.bundle_max_payload_size() );
config.SET_STORABLE( bundle, compression_method,
storageInfo.default_compression_method() );

ExtendedStorageInfoFile::save( getExtendedStorageInfoPath(), encryptionkey,
extendedStorageInfo );

verbosePrintf( "Done.\n" );
verbosePrintf( "Done.\n" );

return loadExtendedStorageInfo( encryptionkey );
return loadExtendedStorageInfo( encryptionkey );
}
else
{
fprintf( stderr, "info_extended exists but can't be opened!\n"
"Please check file permissions.\n" );
}
}
}

Expand Down

0 comments on commit 5be6d7f

Please sign in to comment.