2516 deduplicate attachements on compaction

This is replacing PR https://github.com/apache/couchdb-couch/pull/22