From d6cb627fadc2e570496b737ab18b3028bf27f3c1 Mon Sep 17 00:00:00 2001 From: Vladimir Stackov Date: Tue, 4 Aug 2015 16:03:51 +0300 Subject: [PATCH] Fix for #70 Reindexing feauture coming soon --- backup_collector.cc | 19 +++++++++++-------- backup_collector.hh | 1 - zutils.cc | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backup_collector.cc b/backup_collector.cc index ba5f01e..147f874 100644 --- a/backup_collector.cc +++ b/backup_collector.cc @@ -27,9 +27,15 @@ void BundleCollector::finishIndex( string const & indexFn ) { if ( indexModified ) { - verbosePrintf( "Chunks: %d used / %d total, bundles: %d kept / %d modified / %d removed\n", - indexUsedChunks, indexTotalChunks, indexKeptBundles, indexModifiedBundles, indexRemovedBundles); + verbosePrintf( "Chunks used: %d/%d, bundles: %d kept, %d modified, %d removed\n", + indexUsedChunks, indexTotalChunks, indexKeptBundles, + indexModifiedBundles, indexRemovedBundles); filesToUnlink.push_back( indexFn ); + commit(); + } + else + { + chunkStorageWriter->reset(); } } @@ -56,16 +62,14 @@ void BundleCollector::finishBundle( Bundle::Id const & bundleId, BundleInfo cons indexUsedChunks += usedChunks; if ( usedChunks == 0 ) { - if ( verbose ) - printf( "delete %s\n", i.c_str() ); + verbosePrintf( "Deleting %s bundle\n", i.c_str() ); filesToUnlink.push_back( Dir::addPath( bundlesPath, i ) ); indexModified = true; indexRemovedBundles++; } else if ( usedChunks < totalChunks ) { - if ( verbose ) - printf( "%s: used %d/%d\n", i.c_str(), usedChunks, totalChunks ); + verbosePrintf( "%s: used %d/%d chunks\n", i.c_str(), usedChunks, totalChunks ); filesToUnlink.push_back( Dir::addPath( bundlesPath, i ) ); indexModified = true; // Copy used chunks to the new index @@ -86,8 +90,7 @@ void BundleCollector::finishBundle( Bundle::Id const & bundleId, BundleInfo cons else { chunkStorageWriter->addBundle( info, savedId ); - if ( verbose ) - printf( "keep %s\n", i.c_str() ); + verbosePrintf( "Keeping %s bundle\n", i.c_str() ); indexKeptBundles++; } } diff --git a/backup_collector.hh b/backup_collector.hh index eba1ba3..96669e7 100644 --- a/backup_collector.hh +++ b/backup_collector.hh @@ -32,7 +32,6 @@ private: public: string bundlesPath; - bool verbose; ChunkStorage::Reader *chunkStorageReader; ChunkStorage::Writer *chunkStorageWriter; BackupRestorer::ChunkSet usedChunkSet; diff --git a/zutils.cc b/zutils.cc index 0675946..d57a524 100644 --- a/zutils.cc +++ b/zutils.cc @@ -322,7 +322,6 @@ void ZCollector::gc() collector.bundlesPath = getBundlesPath(); collector.chunkStorageReader = &this->chunkStorageReader; collector.chunkStorageWriter = &chunkStorageWriter; - collector.verbose = false; verbosePrintf( "Checking used chunks...\n" );