Author: stefan2
Date: Sun Apr 19 19:02:59 2015
New Revision: 1674669
URL: http://svn.apache.org/r1674669
Log:
Follow-up on r1674341:
Make sure the new REPs have already been sufficiently initialized before
comparing them with rep-cache.db contents. Moreover, the fixup code needs
to handle missing MD5 digests in reps because the rep cache does not store
those.
* subversion/libsvn_fs_fs/cached_data.c
(svn_fs_fs__fixup_expanded_size): Only claim a MD5 mismatch if the digest
was acually given. Fall back to SHA1
if available.
* subversion/libsvn_fs_fs/transaction.c
(write_container_rep,
write_container_delta_rep): Make sure the EXPANDED_SIZE element has been
initialized before comparing it.
Modified:
subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
subversion/trunk/subversion/libsvn_fs_fs/transaction.c
Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1674669&r1=1674668&r2=1674669&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Sun Apr 19 19:02:59
2015
@@ -291,6 +291,7 @@ svn_fs_fs__fixup_expanded_size(svn_fs_t
representation_t *rep,
apr_pool_t *scratch_pool)
{
+ svn_checksum_t checksum;
svn_checksum_t *empty_md5;
svn_fs_fs__revision_file_t *revision_file;
svn_fs_fs__rep_header_t *rep_header;
@@ -307,14 +308,37 @@ svn_fs_fs__fixup_expanded_size(svn_fs_t
/* EXPANDED_SIZE is 0. If the MD5 does not match the one for empty
* contents, we know that EXPANDED_SIZE == 0 is wrong and needs to
- * be set to the actual value given by SIZE. */
+ * be set to the actual value given by SIZE.
+ *
+ * Using svn_checksum_match() will also accept all-zero values for
+ * the MD5 digest and only report a mismatch if the MD5 has actually
+ * been given. */
empty_md5 = svn_checksum_empty_checksum(svn_checksum_md5, scratch_pool);
- if (memcmp(empty_md5->digest, rep->md5_digest, sizeof(rep->md5_digest)))
+
+ checksum.digest = rep->md5_digest;
+ checksum.kind = svn_checksum_md5;
+ if (!svn_checksum_match(empty_md5, &checksum))
{
rep->expanded_size = rep->size;
return SVN_NO_ERROR;
}
+ /* Data in the rep-cache.db does not have MD5 checksums (all zero) on it.
+ * Compare SHA1 instead. */
+ if (rep->has_sha1)
+ {
+ svn_checksum_t *empty_sha1
+ = svn_checksum_empty_checksum(svn_checksum_sha1, scratch_pool);
+
+ checksum.digest = rep->sha1_digest;
+ checksum.kind = svn_checksum_sha1;
+ if (!svn_checksum_match(empty_sha1, &checksum))
+ {
+ rep->expanded_size = rep->size;
+ return SVN_NO_ERROR;
+ }
+ }
+
/* Only two cases are left here.
* (1) A non-empty PLAIN rep with a MD5 collision on EMPTY_MD5.
* (2) A DELTA rep with zero-length output. */
Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1674669&r1=1674668&r2=1674669&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Sun Apr 19 19:02:59
2015
@@ -2548,6 +2548,7 @@ write_container_rep(representation_t *re
/* Check and see if we already have a representation somewhere that's
identical to the one we just wrote out. */
+ rep->expanded_size = whb->size;
SVN_ERR(get_shared_rep(&old_rep, fs, rep, reps_hash, scratch_pool,
scratch_pool));
@@ -2583,7 +2584,6 @@ write_container_rep(representation_t *re
/* update the representation */
rep->size = whb->size;
- rep->expanded_size = whb->size;
}
return SVN_NO_ERROR;
@@ -2687,6 +2687,7 @@ write_container_delta_rep(representation
/* Check and see if we already have a representation somewhere that's
identical to the one we just wrote out. */
+ rep->expanded_size = whb->size;
SVN_ERR(get_shared_rep(&old_rep, fs, rep, reps_hash, scratch_pool,
scratch_pool));
@@ -2722,7 +2723,6 @@ write_container_delta_rep(representation
SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
/* update the representation */
- rep->expanded_size = whb->size;
rep->size = rep_end - delta_start;
}