Check-in [6dab6149b1]
Not logged in
Overview

SHA1 Hash:6dab6149b13f9fdb214a279d2b3c47619f3eb7b6
Date: 2007-08-01 13:32:11
User: drh
Comment:From the vinfo webpage, provide a hyperlink to download a ZIP archive the version.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/cgi.c from [0b7697e1bf] to [90e1185c4a].

@@ -99,10 +99,19 @@
 /*
 ** Set the reply content type
 */
 void cgi_set_content_type(const char *zType){
   zContentType = mprintf("%s", zType);
+}
+
+/*
+** Set the reply content to the specified BLOB.
+*/
+void cgi_set_content(Blob *pNewContent){
+  blob_reset(&cgiContent);
+  cgiContent = *pNewContent;
+  blob_zero(pNewContent);
 }
 
 /*
 ** Set the reply status code
 */

Modified src/info.c from [1c93e96623] to [512979df91].

@@ -215,16 +215,18 @@
      " WHERE blob.rid=%d"
      "   AND event.objid=%d",
      rid, rid
   );
   if( db_step(&q)==SQLITE_ROW ){
-    @ <h2>Version %s(db_column_text(&q,0))</h2>
+    const char *zUuid = db_column_text(&q, 0);
+    @ <h2>Version %s(zUuid)</h2>
     @ <ul>
     @ <li><b>Date:</b> %s(db_column_text(&q, 1))</li>
     @ <li><b>User:</b> %s(db_column_text(&q, 2))</li>
     @ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li>
     @ <li><a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a></li>
+    @ <li><a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a></li>
     @ </ul>
   }
   db_finalize(&q);
   @ <p><h2>Descendents:</h2>
   n = showDescendents(rid, 2);

Modified src/xfer.c from [0ffca46ab7] to [3a9a49107f].

@@ -656,11 +656,11 @@
             if( db_changes()>0 ){
               go = 1;
             }
           }
           if( pullFlag && !go &&
-              db_exists("SELECT 1 FROM blob WHERE rid=%d AND size<=0", rid) ){
+              db_exists("SELECT 1 FROM blob WHERE rid=%d AND size<0", rid) ){
             go = 1;
           }
         }else if( pullFlag ){
           go = 1;
           content_put(0, blob_str(&aToken[1]));

Modified src/zip.c from [8d50d34cbb] to [a664fdc0f6].

@@ -313,6 +313,39 @@
   }
   db_must_be_within_tree();
   rid = name_to_rid(g.argv[2]);
   zip_of_baseline(rid, &zip);
   blob_write_to_file(&zip, g.argv[3]);
+}
+
+/*
+** WEBPAGE: zip
+**
+** Generate a ZIP archive for the baseline specified by g.zExtra
+** and return that ZIP archive as the HTTP reply content.
+*/
+void baseline_zip_page(void){
+  int rid;
+  char *zName;
+  int i;
+  Blob zip;
+
+  login_check_credentials();
+  if( !g.okRead || !g.okHistory ){ login_needed(); return; }
+  zName = mprintf("%s", g.zExtra);
+  i = strlen(zName);
+  for(i=strlen(zName)-1; i>5; i--){
+    if( zName[i]=='.' ){
+      zName[i] = 0;
+      break;
+    }
+  }
+  rid = name_to_rid(zName);
+  if( rid==0 ){
+    @ Not found
+    return;
+  }
+  zip_of_baseline(rid, &zip);
+  cgi_set_content(&zip);
+  cgi_set_content_type("application/zip");
+  cgi_reply();
 }