Diff
Not logged in

Differences From:

File src/vfile.c part of check-in [573a464cb7] - Complete rework of the xfer mechanism. Compiles but not yet working. by drh on 2007-08-10 00:08:25. [view]

To:

File src/vfile.c part of check-in [8c828207a2] - Give an error if an attempt is made to merge, update, or checkout against an incomplete baseline - one that contains phantoms. Update the xfer protocol to converge on a stable synchronization faster and (hopeful) not quit until the sync is complete. by drh on 2007-08-27 00:04:32. Also file src/vfile.c part of check-in [15652ff081] - Merged drh's fixes new features (xfer, timeline handling, javascript based timeline highlighting) into my branch. by aku on 2007-08-29 02:55:33. [view]

@@ -56,8 +56,27 @@
   return rid;
 }
 
 /*
+** Verify that an object is not a phantom.  If the object is
+** a phantom, output an error message and quick.
+*/
+void vfile_verify_not_phantom(int rid, const char *zFilename){
+  if( db_int(-1, "SELECT size FROM blob WHERE rid=%d", rid)<0 ){
+    if( zFilename ){
+      fossil_fatal("content missing for %s", zFilename);
+    }else{
+      char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
+      if( zUuid ){
+        fossil_fatal("content missing for [%.10s]", zUuid);
+      }else{
+        fossil_panic("bad object id: %d", rid);
+      }
+    }
+  }
+}
+
+/*
 ** Build a catalog of all files in a baseline.
 ** We scan the baseline file for lines of the form:
 **
 **     F NAME UUID
@@ -70,8 +89,9 @@
   Stmt ins;
   Blob line, token, name, uuid;
   int seenHeader = 0;
   db_begin_transaction();
+  vfile_verify_not_phantom(vid, 0);
   db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
   db_prepare(&ins,
     "INSERT INTO vfile(vid,rid,mrid,pathname) "
     " VALUES(:vid,:id,:id,:name)");
@@ -91,8 +111,9 @@
     zName = blob_str(&name);
     defossilize(zName);
     zUuid = blob_str(&uuid);
     rid = uuid_to_rid(zUuid, 0);
+    vfile_verify_not_phantom(rid, zName);
     if( rid>0 && file_is_simple_pathname(zName) ){
       db_bind_int(&ins, ":id", rid);
       db_bind_text(&ins, ":name", zName);
       db_step(&ins);