couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r652489 - in /incubator/couchdb/trunk: share/www/script/couch.js share/www/script/couch_tests.js share/www/script/shell.js src/couchdb/couch_stream.erl
Date Thu, 01 May 2008 12:07:52 GMT
Author: damien
Date: Thu May  1 05:07:52 2008
New Revision: 652489

URL: http://svn.apache.org/viewvc?rev=652489&view=rev
Log:
fix for compaction problem with attachments, and enhancements to JS shell, to make debugging
tests easier.

Modified:
    incubator/couchdb/trunk/share/www/script/couch.js
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/share/www/script/shell.js
    incubator/couchdb/trunk/src/couchdb/couch_stream.erl

Modified: incubator/couchdb/trunk/share/www/script/couch.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch.js?rev=652489&r1=652488&r2=652489&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch.js [utf-8] Thu May  1 05:07:52 2008
@@ -87,7 +87,7 @@
     var result = JSON.parse(req.responseText);
     if (req.status != 201)
       throw result;
-    for(i in docs) {
+    for(var i in docs) {
         docs[i]._rev = result.new_revs[i].rev;
     }
     return result;

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=652489&r1=652488&r2=652489&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Thu May  1 05:07:52 2008
@@ -849,6 +849,20 @@
     var docs = makeDocs(0, 10);
     var saveResult = db.bulkSave(docs);
     T(saveResult.ok);
+    
+
+    var binAttDoc = {
+      _id:"bin_doc",
+      _attachments:{
+        "foo.txt": {
+          "content-type":"text/plain",
+          "data": "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+        }
+      }
+    }
+
+    T(db.save(binAttDoc).ok);
+    
     var originalsize = db.info().disk_size;
     
     for(var i in docs) {
@@ -862,6 +876,12 @@
     //compaction isn't instantaneous, loop until done
     while(db.info().compact_running) {};
     
+    
+
+    var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
+    T(xhr.responseText == "This is a base64 encoded text")
+    T(xhr.getResponseHeader("content-type") == "text/plain")
+    
     var compactedsize = db.info().disk_size;
     
     T(deletesize > originalsize);

Modified: incubator/couchdb/trunk/share/www/script/shell.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/shell.js?rev=652489&r1=652488&r2=652489&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/shell.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/shell.js [utf-8] Thu May  1 05:07:52 2008
@@ -698,3 +698,25 @@
   // Evaluate Shell.question using _win's eval (this is why eval isn't in the |with|, IIRC).
   _win.location.href = "javascript:try{ Shell.printAnswer(eval('with(Shell._scope) with(Shell.shellCommands)
{' + Shell.question + String.fromCharCode(10) + '}')); } catch(er) { Shell.printError(er);
}; setTimeout(Shell.refocus, 0); void 0";
 }
+
+function T(Bool) {
+    if(!Bool) {
+        throw "Error!";
+    }
+}
+
+
+function makeDocs(start, end, templateDoc) {
+  var templateDocSrc = templateDoc ? templateDoc.toSource() : "{}"
+  var docs = []
+  for(var i=start; i<end; i++) {
+    var newDoc = eval("(" + templateDocSrc + ")");
+    newDoc._id = (i).toString();
+    newDoc.integer = i
+    newDoc.string = (i).toString();
+    docs.push(newDoc)
+  }
+  return docs;
+}
+
+

Modified: incubator/couchdb/trunk/src/couchdb/couch_stream.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_stream.erl?rev=652489&r1=652488&r2=652489&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_stream.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_stream.erl Thu May  1 05:07:52 2008
@@ -90,7 +90,7 @@
     {ok, NewSp, _Sp2} = stream_data(Fd, Sp, Len, ?HUGE_CHUNK,
         fun(Bin, AccPointer) ->
             {ok, NewPointer} = write(DestStream, Bin),
-            if AccPointer == null -> NewPointer; true -> AccPointer end
+            {ok, if AccPointer == null -> NewPointer; true -> AccPointer end}
         end,
         null),
     {ok, NewSp}.



Mime
View raw message