From 1ac0c454ef67468eeea13bec558b5fb11105e2e7 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Tue, 15 Jul 2008 16:27:19 -0700 Subject: [PATCH] Rebuild sub-block signatures when --rebuild-statcache is specified. --- scandir.cc | 4 ++++ subfile.cc | 9 +++++++-- subfile.h | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/scandir.cc b/scandir.cc index 176cb21..ef7833c 100644 --- a/scandir.cc +++ b/scandir.cc @@ -270,6 +270,10 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, subfile.analyze_new_block(block_buf, bytes); refs = subfile.create_incremental(tss, o, block_age); } else { + if (flag_rebuild_statcache && ref.is_normal()) { + subfile.analyze_new_block(block_buf, bytes); + subfile.store_analyzed_signatures(ref); + } refs.push_back(ref); } diff --git a/subfile.cc b/subfile.cc index df6d3b2..4f8d0fe 100644 --- a/subfile.cc +++ b/subfile.cc @@ -195,6 +195,12 @@ void Subfile::store_block_signatures(ObjectReference ref, block_summary summary) free(packed); } +void Subfile::store_analyzed_signatures(ObjectReference ref) +{ + if (analyzed_len >= 16384) + store_block_signatures(ref, new_block_summary); +} + /* Compute an incremental representation of the most recent block analyzed. */ enum subfile_item_type { SUBFILE_COPY, SUBFILE_NEW }; @@ -265,8 +271,7 @@ list Subfile::create_incremental(TarSegmentStore *tss, o->write(tss); ObjectReference ref = o->get_ref(); db->StoreObject(ref, block_csum, analyzed_len, block_age); - if (analyzed_len >= 16384) - store_block_signatures(ref, new_block_summary); + store_analyzed_signatures(ref); ref.set_range(0, analyzed_len, true); refs.push_back(ref); delete o; diff --git a/subfile.h b/subfile.h index e80f76c..3127456 100644 --- a/subfile.h +++ b/subfile.h @@ -51,6 +51,11 @@ public: // buffer until all operations referring to it are finished. void analyze_new_block(const char *buf, size_t len); + // Store the signatures for the most recently-analyzed block in the local + // database (linked to the specified object), if the block is sufficiently + // large. If signatures already exist, they will be overwritten. + void store_analyzed_signatures(ObjectReference ref); + std::list create_incremental(TarSegmentStore *tss, LbsObject *o, double block_age); -- 2.20.1