#include <set>
#include "format.h"
+#include "localdb.h"
#include "store.h"
#include "sha1.h"
static const size_t LBS_METADATA_BLOCK_SIZE = 65536;
+/* Local database, which tracks objects written in this and previous
+ * invocations to help in creating incremental snapshots. */
+LocalDb *db;
+
/* Contents of the root object. This will contain a set of indirect links to
* the metadata objects. */
std::ostringstream metadata_root;
o->write(tss);
object_list.push_back(o->get_name());
segment_list.insert(o->get_ref().get_segment());
- delete o;
+
+ // Index this block so it can be used by future snapshots
+ SHA1Checksum block_hash;
+ block_hash.process(block_buf, bytes);
+ db->StoreObject(o->get_ref(), block_hash.checksum_str(), bytes);
size += bytes;
+
+ delete o;
}
file_info["checksum"] = hash.checksum_str();
tss = new TarSegmentStore(backup_dest);
+ string database_path = backup_dest + "/localdb.sqlite";
+ db = new LocalDb;
+ db->Open(database_path.c_str());
+
/* Write a backup descriptor file, which says which segments are needed and
* where to start to restore this snapshot. The filename is based on the
* current time. */
descriptor << " " << *i << "\n";
}
+ db->Close();
+
tss->sync();
delete tss;