You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Jan Lehnardt <ja...@apache.org> on 2008/07/17 01:52:11 UTC

Posting empty attachments

Heya Damien,
the recently added RESTful API for attachments still lacks
support for empty attachments. CouchDB will fail in
the couch_db:doc_flush_binaries/2 function. The following
patch makes my (new) testcase of writing and reading an
empty attachment work, but I am sure it is not completely
correct. Also, I am not yet entirely sure if that is the right
place to fix that. Any pointers appreciated :)


Cheers
Jan
--
Index: /Users/jan/Work/couchdb-all/trunk/src/couchdb/couch_db.erl
===================================================================
--- /Users/jan/Work/couchdb-all/trunk/src/couchdb/couch_db.erl	 
(revision 675780)
+++ /Users/jan/Work/couchdb-all/trunk/src/couchdb/couch_db.erl	 
(working copy)
@@ -348,6 +348,9 @@
          fun({Key, {Type, BinValue}}) ->
              NewBinValue =
              case BinValue of
+            <<>> ->
+                % empty attachment
+                {0, 0, 0};
              {Fd0, StreamPointer, Len} when Fd0 == Fd ->
                  % already written to our file, nothing to write
                  {Fd, StreamPointer, Len};