Rebuild sub-block signatures when --rebuild-statcache is specified.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 15 Jul 2008 23:27:19 +0000 (16:27 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Tue, 15 Jul 2008 23:27:19 +0000 (16:27 -0700)
scandir.cc
subfile.cc
subfile.h

index 176cb21..ef7833c 100644 (file)
@@ -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);
             }
 
index df6d3b2..4f8d0fe 100644 (file)
@@ -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<ObjectReference> 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;
index e80f76c..3127456 100644 (file)
--- 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<ObjectReference> create_incremental(TarSegmentStore *tss,
                                                   LbsObject *o,
                                                   double block_age);