issues@subversion.tigris.org writes:
> + ------- Additional Comments From ghudson@tigris.org 2003-03-26 13:06 PST -------
> + The problem with the fix in 5474 is that, in the future, no more
> + fields can be added to the get-file response tuple in a
> + backwards-compatible fashion, because the checksum isn't always sent
> + even by new code. That's why I suggested replacing the "c" with a
> + "(?c)" instead of replacing it with a "?c" at the end.
(Thanks for reviewing the commit.)
I actually tried that first, but still some tests failed, in
particular anything involving a switch -- basic_tests 10 for example.
I confess I never did understand exactly what was wrong with it; I
just found another solution. The extensibility problem didn't occur
to me, but it makes sense now that you explain it.
Here is that first patch. Maybe there's just some braino here?
* subversion/libsvn_ra_svn/client.c
(ra_svn_get_file): Read expected_checksum as an optional tuple,
and skip checksum code if don't get a checksum.
* subversion/svnserve/serve.c
(get_file): Send hex_digest as an optional tuple.
Index: subversion/libsvn_ra_svn/client.c
===================================================================
--- subversion/libsvn_ra_svn/client.c (revision 5467)
+++ subversion/libsvn_ra_svn/client.c (working copy)
@@ -526,7 +526,7 @@
SVN_ERR(svn_ra_svn_write_cmd(conn, pool, "get-file", "c(?r)bb", path,
rev, (props != NULL), (stream != NULL)));
- SVN_ERR(svn_ra_svn_read_cmd_response(conn, pool, "crl",
+ SVN_ERR(svn_ra_svn_read_cmd_response(conn, pool, "(?c)rl",
&expected_checksum,
&rev, &proplist));
@@ -539,7 +539,8 @@
if (!stream)
return SVN_NO_ERROR;
- apr_md5_init(&md5_context);
+ if (expected_checksum)
+ apr_md5_init(&md5_context);
/* Read the file's contents. */
while (1)
@@ -551,20 +552,27 @@
if (item->u.string->len == 0)
break;
- apr_md5_update(&md5_context, item->u.string->data, item->u.string->len);
+ if (expected_checksum)
+ apr_md5_update(&md5_context, item->u.string->data,
+ item->u.string->len);
SVN_ERR(svn_stream_write(stream, item->u.string->data,
&item->u.string->len));
}
- apr_md5_final(digest, &md5_context);
- hex_digest = svn_md5_digest_to_cstring(digest, pool);
- if (strcmp(hex_digest, expected_checksum) != 0)
- return svn_error_createf(SVN_ERR_CHECKSUM_MISMATCH, NULL,
- "ra_svn_get_file: checksum mismatch for '%s':\n"
- " expected checksum: %s\n"
- " actual checksum: %s\n",
- path, expected_checksum, hex_digest);
+ if (expected_checksum)
+ {
+ apr_md5_final(digest, &md5_context);
+ hex_digest = svn_md5_digest_to_cstring(digest, pool);
+
+ if (strcmp(hex_digest, expected_checksum) != 0)
+ return svn_error_createf
+ (SVN_ERR_CHECKSUM_MISMATCH, NULL,
+ "ra_svn_get_file: checksum mismatch for '%s':\n"
+ " expected checksum: %s\n"
+ " actual checksum: %s\n",
+ path, expected_checksum, hex_digest);
+ }
SVN_ERR(svn_stream_close(stream));
return SVN_NO_ERROR;
Index: subversion/svnserve/serve.c
===================================================================
--- subversion/svnserve/serve.c (revision 5467)
+++ subversion/svnserve/serve.c (working copy)
@@ -408,7 +408,7 @@
SVN_ERR(svn_ra_svn_start_list(conn, pool));
SVN_ERR(svn_ra_svn_write_word(conn, pool, "success"));
SVN_ERR(svn_ra_svn_start_list(conn, pool));
- SVN_ERR(svn_ra_svn_write_cstring(conn, pool, hex_digest));
+ SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "(?c)", hex_digest));
SVN_ERR(svn_ra_svn_write_number(conn, pool, rev));
SVN_ERR(write_proplist(conn, pool, props));
SVN_ERR(svn_ra_svn_end_list(conn, pool));
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 26 22:19:05 2003