Make use of size assertions in references where possible.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Thu, 10 Jul 2008 18:05:19 +0000 (11:05 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Thu, 10 Jul 2008 18:05:19 +0000 (11:05 -0700)
When writing out a reference to what is known to be a complete object, use
the size-assertion form of a reference.

localdb.cc
ref.cc
subfile.cc

index cc8a83c..7d93bb1 100644 (file)
@@ -295,7 +295,7 @@ ObjectReference LocalDb::FindObject(const string &checksum, int64_t size)
     } else if (rc == SQLITE_ROW) {
         ref = ObjectReference(IdToSegment(sqlite3_column_int64(stmt, 0)),
                               (const char *)sqlite3_column_text(stmt, 1));
-        ref.set_range(0, size);
+        ref.set_range(0, size, true);
     } else {
         fprintf(stderr, "Could not execute SELECT statement!\n");
         ReportError(rc);
diff --git a/ref.cc b/ref.cc
index 7e92b7a..4020c01 100644 (file)
--- a/ref.cc
+++ b/ref.cc
@@ -99,7 +99,7 @@ string ObjectReference::to_string() const
         char buf[64];
         if (range_exact) {
             sprintf(buf, "[=%zu]", range_length);
-        } else if (range_start == 0) {
+        } else if (type == REF_ZERO) {
             sprintf(buf, "[%zu]", range_length);
         } else {
             sprintf(buf, "[%zu+%zu]", range_start, range_length);
index dac7eda..df6d3b2 100644 (file)
@@ -267,6 +267,7 @@ list<ObjectReference> Subfile::create_incremental(TarSegmentStore *tss,
         db->StoreObject(ref, block_csum, analyzed_len, block_age);
         if (analyzed_len >= 16384)
             store_block_signatures(ref, new_block_summary);
+        ref.set_range(0, analyzed_len, true);
         refs.push_back(ref);
         delete o;
         return refs;