Merge pull request #83 from Am1GO/master

Fix for #70
master
Am1GO 2015-08-04 16:08:09 +03:00
commit e76c0db562
3 changed files with 11 additions and 10 deletions

View File

@ -27,9 +27,15 @@ void BundleCollector::finishIndex( string const & indexFn )
{ {
if ( indexModified ) if ( indexModified )
{ {
verbosePrintf( "Chunks: %d used / %d total, bundles: %d kept / %d modified / %d removed\n", verbosePrintf( "Chunks used: %d/%d, bundles: %d kept, %d modified, %d removed\n",
indexUsedChunks, indexTotalChunks, indexKeptBundles, indexModifiedBundles, indexRemovedBundles); indexUsedChunks, indexTotalChunks, indexKeptBundles,
indexModifiedBundles, indexRemovedBundles);
filesToUnlink.push_back( indexFn ); filesToUnlink.push_back( indexFn );
commit();
}
else
{
chunkStorageWriter->reset();
} }
} }
@ -56,16 +62,14 @@ void BundleCollector::finishBundle( Bundle::Id const & bundleId, BundleInfo cons
indexUsedChunks += usedChunks; indexUsedChunks += usedChunks;
if ( usedChunks == 0 ) if ( usedChunks == 0 )
{ {
if ( verbose ) verbosePrintf( "Deleting %s bundle\n", i.c_str() );
printf( "delete %s\n", i.c_str() );
filesToUnlink.push_back( Dir::addPath( bundlesPath, i ) ); filesToUnlink.push_back( Dir::addPath( bundlesPath, i ) );
indexModified = true; indexModified = true;
indexRemovedBundles++; indexRemovedBundles++;
} }
else if ( usedChunks < totalChunks ) else if ( usedChunks < totalChunks )
{ {
if ( verbose ) verbosePrintf( "%s: used %d/%d chunks\n", i.c_str(), usedChunks, totalChunks );
printf( "%s: used %d/%d\n", i.c_str(), usedChunks, totalChunks );
filesToUnlink.push_back( Dir::addPath( bundlesPath, i ) ); filesToUnlink.push_back( Dir::addPath( bundlesPath, i ) );
indexModified = true; indexModified = true;
// Copy used chunks to the new index // Copy used chunks to the new index
@ -86,8 +90,7 @@ void BundleCollector::finishBundle( Bundle::Id const & bundleId, BundleInfo cons
else else
{ {
chunkStorageWriter->addBundle( info, savedId ); chunkStorageWriter->addBundle( info, savedId );
if ( verbose ) verbosePrintf( "Keeping %s bundle\n", i.c_str() );
printf( "keep %s\n", i.c_str() );
indexKeptBundles++; indexKeptBundles++;
} }
} }

View File

@ -32,7 +32,6 @@ private:
public: public:
string bundlesPath; string bundlesPath;
bool verbose;
ChunkStorage::Reader *chunkStorageReader; ChunkStorage::Reader *chunkStorageReader;
ChunkStorage::Writer *chunkStorageWriter; ChunkStorage::Writer *chunkStorageWriter;
BackupRestorer::ChunkSet usedChunkSet; BackupRestorer::ChunkSet usedChunkSet;

View File

@ -322,7 +322,6 @@ void ZCollector::gc()
collector.bundlesPath = getBundlesPath(); collector.bundlesPath = getBundlesPath();
collector.chunkStorageReader = &this->chunkStorageReader; collector.chunkStorageReader = &this->chunkStorageReader;
collector.chunkStorageWriter = &chunkStorageWriter; collector.chunkStorageWriter = &chunkStorageWriter;
collector.verbose = false;
verbosePrintf( "Checking used chunks...\n" ); verbosePrintf( "Checking used chunks...\n" );