Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 16100 invoked from network); 7 Dec 2010 15:35:37 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Dec 2010 15:35:37 -0000 Received: (qmail 41845 invoked by uid 500); 7 Dec 2010 15:35:36 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 41601 invoked by uid 500); 7 Dec 2010 15:35:36 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 41593 invoked by uid 99); 7 Dec 2010 15:35:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Dec 2010 15:35:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FRT_BELOW2 X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Dec 2010 15:35:33 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id oB7FZBTY026282 for ; Tue, 7 Dec 2010 15:35:11 GMT Message-ID: <626672.26071291736111359.JavaMail.jira@thor> Date: Tue, 7 Dec 2010 10:35:11 -0500 (EST) From: "Filipe Manana (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Commented: (COUCHDB-687) Add md5 hash to _attachments properties for documents MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12968789#action_12968789 ] Filipe Manana commented on COUCHDB-687: --------------------------------------- Hi Juuso, Again, thanks for your efforts. I haven't tried the patch, however it looks good in general. My comments bellow. 1) To accept it, I need tests. Test the md5 property for compressible and non-compressible attachments. Test that after a compaction the md5 attribute is still there and with the same value as before the compaction. Test that after every kind of replication (local-local, local-remote, remote-remote, remote-local), the md5 attribute has the same value on the target. Etc. I would add the tests in attachments.js and eventually replication.js. 2) I think it's a bad idea to give it the string value "undefined" when we don't have the attachments' identity md5 (why "undefined" btw?). Simply omitting it from the JSON is the way to go (or at the very least assign it the null value). 3) Here: +to_md5_hex(Binary) -> + ?l2b(lists:flatten(couch_util:to_hex(Binary))). Why the lists:flatten call? Afaik, couch_util:to_hex/1 always returns a string. I would also avoid declaring this function, since it's only used in one place. Simply replace this function call with a direct call to ?l2b(couch_util:to_hex(Bin)). 4) The hex_to_bin/1 function should probably go to couch_util. 5) Here: + try [{<<"md5">>, to_md5_hex(Att#att.identity_md5)}] + catch error: _ -> [{<<"md5">>, <<"undefined">>}] end++ Why the try catch expression? Afaik couch_util:to_hex/1 never throws an exception, even if the argument is an empty binary. 6) I told in your previous submission (other ticket) to keep lines up to 80 characters wide. See http://wiki.apache.org/couchdb/Coding_Standards > Add md5 hash to _attachments properties for documents > ----------------------------------------------------- > > Key: COUCHDB-687 > URL: https://issues.apache.org/jira/browse/COUCHDB-687 > Project: CouchDB > Issue Type: Improvement > Environment: CouchDB > Reporter: mikeal > Assignee: Filipe Manana > Attachments: couchdb-md5-in-attachment-COUCHDB-687.patch, md5.patch > > > The current attachment information looks like this: > GET /dbname/docid > "_attachments": { > "jquery-1.4.1.min.js": { > "content_type": "text/javascript" > "revpos": 138 > "length": 70844 > "stub": true > } > } > If a client wanted to sync local files as attachments with a document it would not currently be able to do so without keeping a local store of the revpos. If this information included an md5 hash of the attachment clients could compare it against a hash of the local file to see if they match. > -Mikeal -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.