Author: poeml Date: Thu Mar 11 23:16:28 2010 New Revision: 7983 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7983&view=rev Log: mod_mirrorbrain: - The hashes for old Metalinks are pulled from the database now. Fallback is to read them from disk, if the database doesn't have hashes. Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=7983&r1=7982&r2=7983&view=diff ============================================================================== --- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original) +++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Thu Mar 11 23:16:28 2010 _at_@ -813,7 +813,7 @@ /* split the string into an array of the actual pieces */ apr_off_t n = r->finfo.size / h->sha1piecesize; - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_mirrorbrain] dbd: %lld sha1 pieces", n); + // XXX ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_mirrorbrain] dbd: %lld sha1 pieces", n); h->sha1pieces = apr_array_make(r->pool, n, sizeof(const char *)); int max = strlen(val); _at_@ -1867,7 +1867,6 @@ r->finfo.mtime / 1000000); /* APR finfo times are in microseconds */ - if (hashbag != NULL) { switch (rep) { case META4: _at_@ -1884,7 +1883,6 @@ if (hashbag->sha256) ap_rprintf(r, " <hash type=\"sha-256\">%s</hash>\n", hashbag->sha256); - if (hashbag->sha1pieces && (hashbag->sha1piecesize > 0) && !apr_is_empty_array(hashbag->sha1pieces)) { _at_@ -1897,15 +1895,47 @@ } ap_rputs(" </pieces>\n", r); } - break; - } - - } - - - - if (rep == METALINK) { + + case METALINK: + /* There are a few slight differences to the newer meta4 format */ + ap_rputs(" <verification>\n", r); + + if (hashbag->pgp) { + ap_rputs(" <signature mediatype=\"application/pgp-signature\">\n", r); + ap_rputs(hashbag->pgp, r); + ap_rputs(" </signature>\n", r); + } + + if (hashbag->md5) + ap_rprintf(r, " <hash type=\"md5\">%s</hash>\n", hashbag->md5); + if (hashbag->sha256) + ap_rprintf(r, " <hash type=\"sha1\">%s</hash>\n", hashbag->sha1); + if (hashbag->sha256) + ap_rprintf(r, " <hash type=\"sha256\">%s</hash>\n", hashbag->sha256); + + if (hashbag->sha1pieces + && (hashbag->sha1piecesize > 0) + && !apr_is_empty_array(hashbag->sha1pieces)) { + ap_rprintf(r, " <pieces length=\"%d\" type=\"sha1\">\n", + hashbag->sha1piecesize); + + char **p = (char **)hashbag->sha1pieces->elts; + for (i = 0; i < hashbag->sha1pieces->nelts; i++) { + ap_rprintf(r, " <hash piece=\"%d\">%s</hash>\n", i, p[i]); + } + ap_rputs(" </pieces>\n", r); + } + + ap_rputs(" </verification>\n", r); + + break; + } + + } + + + if (!hashbag && rep == METALINK) { /* if the above failed, and we are creating a v3 metalink, let's try the old on-disk format */ apr_finfo_t sb; const char *hashfilename; _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Thu Mar 11 2010 - 22:16:29 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT