2014-12-11 10:50:15 +03:00
|
|
|
// Copyright (c) 2012-2014 Konstantin Isakov <ikm@zbackup.org> and ZBackup contributors, see CONTRIBUTORS
|
2014-11-27 19:20:41 +03:00
|
|
|
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
|
|
|
|
|
2015-01-25 19:44:15 +03:00
|
|
|
#ifndef BACKUP_COLLECTOR_HH_INCLUDED
|
|
|
|
#define BACKUP_COLLECTOR_HH_INCLUDED
|
2014-11-27 19:20:41 +03:00
|
|
|
|
2015-02-04 14:38:22 +03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "backup_restorer.hh"
|
|
|
|
#include "backup_file.hh"
|
|
|
|
|
|
|
|
#include "debug.hh"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
class BundleCollector: public IndexProcessor
|
2014-11-27 19:20:41 +03:00
|
|
|
{
|
2015-02-04 14:38:22 +03:00
|
|
|
private:
|
|
|
|
Bundle::Id savedId;
|
|
|
|
int totalChunks, usedChunks, indexTotalChunks, indexUsedChunks;
|
|
|
|
int indexModifiedBundles, indexKeptBundles, indexRemovedBundles;
|
2015-08-12 16:27:54 +03:00
|
|
|
bool indexModified, indexNecessary;
|
2015-02-04 14:38:22 +03:00
|
|
|
vector< string > filesToUnlink;
|
2015-08-12 16:27:54 +03:00
|
|
|
BackupRestorer::ChunkSet overallChunkSet;
|
2015-08-18 19:02:12 +03:00
|
|
|
std::set< Bundle::Id > overallBundleSet;
|
2014-11-27 19:20:41 +03:00
|
|
|
|
2015-08-18 17:27:27 +03:00
|
|
|
void copyUsedChunks( BundleInfo const & info );
|
|
|
|
|
2014-11-27 19:20:41 +03:00
|
|
|
public:
|
2015-02-04 14:38:22 +03:00
|
|
|
string bundlesPath;
|
|
|
|
ChunkStorage::Reader *chunkStorageReader;
|
|
|
|
ChunkStorage::Writer *chunkStorageWriter;
|
|
|
|
BackupRestorer::ChunkSet usedChunkSet;
|
2015-08-19 10:32:16 +03:00
|
|
|
bool gcRepack, gcDeep;
|
2015-02-04 14:38:22 +03:00
|
|
|
|
|
|
|
void startIndex( string const & indexFn );
|
|
|
|
|
|
|
|
void finishIndex( string const & indexFn );
|
|
|
|
|
|
|
|
void startBundle( Bundle::Id const & bundleId );
|
|
|
|
|
2015-05-21 01:15:10 +03:00
|
|
|
void processChunk( ChunkId const & chunkId, uint32_t size );
|
2015-02-04 14:38:22 +03:00
|
|
|
|
|
|
|
void finishBundle( Bundle::Id const & bundleId, BundleInfo const & info );
|
2014-11-27 19:20:41 +03:00
|
|
|
|
2015-02-04 14:38:22 +03:00
|
|
|
void commit();
|
2014-11-27 19:20:41 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|