Diff
Not logged in

Differences From:

File src/rebuild.c part of check-in [6458f020fc] - Change the spelling of "descendant" to use the -ant suffix everywhere, including in the filename "descendant.c". The adjective form can be spelled either -ant or -ent, but the noun form requires -ant, or so says American Heritage. by drh on 2008-05-14 02:03:45. [view]

To:

File src/rebuild.c part of check-in [5b74febbcc] - The rebuild command corrects any errors seen in the blob.size field. by drh on 2008-05-16 17:05:05. [view]

@@ -51,8 +51,18 @@
 @    title text,              -- Title of this report
 @    cols text,               -- A color-key specification
 @    sqlcode text             -- An SQL SELECT statement for this report
 @ );
+@
+@ -- A cache for mapping baseline artifact ID + filename into file
+@ -- artifact ID.  Used by the /doc method.
+@ --
+@ CREATE TABLE IF NOT EXISTS vcache(
+@    vid integer,             -- Baseline artifact ID
+@    fname text,              -- Filename
+@    rid integer,             -- File artifact ID
+@    UNIQUE(vid,fname,rid)
+@ );
 ;
 
 /*
 ** Variables used for progress information
@@ -76,14 +86,21 @@
 ** Rebuild cross-referencing information for the artifact
 ** rid with content pBase and all of its descendants.  This
 ** routine clears the content buffer before returning.
 */
-static void rebuild_step(int rid, Blob *pBase){
+static void rebuild_step(int rid, int size, Blob *pBase){
   Stmt q1;
   Bag children;
   Blob copy;
   Blob *pUse;
   int nChild, i, cid;
+
+  /* Fix up the "blob.size" field if needed. */
+  if( size!=blob_size(pBase) ){
+    db_multi_exec(
+       "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid
+    );
+  }
 
   /* Find all children of artifact rid */
   db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid);
   bag_init(&children);
@@ -120,9 +137,9 @@
       blob_uncompress(&delta, &delta);
       blob_delta_apply(pUse, &delta, pUse);
       blob_reset(&delta);
       db_finalize(&q2);
-      rebuild_step(cid, pUse);
+      rebuild_step(cid, sz, pUse);
     }else{
       db_finalize(&q2);
       blob_reset(pUse);
     }
@@ -182,9 +199,9 @@
     int size = db_column_int(&s, 1);
     if( size>=0 ){
       Blob content;
       content_get(rid, &content);
-      rebuild_step(rid, &content);
+      rebuild_step(rid, size, &content);
     }else{
       db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
       rebuild_step_done();
     }