Check-in [5c74c300b1]
Not logged in
Overview

SHA1 Hash:5c74c300b11f2f89da7562adec32a7909f9efe22
Date: 2007-08-04 00:38:38
User: drh
Comment:Changes to the checksum verification steps to allow a partial commit of changes after new files are added to the tree.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/vfile.c from [520337f87b] to [47b5a77023].

@@ -257,10 +257,12 @@
 **
 ** This function operates differently if the Global.aCommitFile
 ** variable is not NULL. In that case, the disk image is used for
 ** each file in aCommitFile[] and the repository image (see
 ** vfile_aggregate_checksum_repository() is used for all others).
+** Newly added files that are not contained in the repository are
+** omitted from the checksum if they are not in Global.aCommitFile.
 **
 ** Return the resulting checksum in blob pOut.
 */
 void vfile_aggregate_checksum_disk(int vid, Blob *pOut){
   FILE *in;
@@ -278,13 +280,12 @@
   while( db_step(&q)==SQLITE_ROW ){
     const char *zFullpath = db_column_text(&q, 0);
     const char *zName = db_column_text(&q, 1);
     int isSelected = db_column_int(&q, 2);
 
-    md5sum_step_text(zName, -1);
-
     if( isSelected ){
+      md5sum_step_text(zName, -1);
       in = fopen(zFullpath,"rb");
       if( in==0 ){
         md5sum_step_text(" 0\n", -1);
         continue;
       }
@@ -302,16 +303,19 @@
     }else{
       int rid = db_column_int(&q, 3);
       char zBuf[100];
       Blob file;
 
-      blob_zero(&file);
-      content_get(rid, &file);
-      sprintf(zBuf, " %d\n", blob_size(&file));
-      md5sum_step_text(zBuf, -1);
-      md5sum_step_blob(&file);
-      blob_reset(&file);
+      if( rid>0 ){
+        md5sum_step_text(zName, -1);
+        blob_zero(&file);
+        content_get(rid, &file);
+        sprintf(zBuf, " %d\n", blob_size(&file));
+        md5sum_step_text(zBuf, -1);
+        md5sum_step_blob(&file);
+        blob_reset(&file);
+      }
     }
   }
   db_finalize(&q);
   md5sum_finish(pOut);
 }